-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modified subquery in PostgreSqlPlatform->getListTableForeignKeysSQL() #3422
Conversation
Please format your commit message according to these rules :
Bad example :
Good example:
More details in CONTRIBUTING.md |
Change looks good, but I'm wondering if there is a way to test this patch? |
In order to reproduce this error you need to have a postgres database that has two schemas that have a table with the same name:
Then to trigger the error, fetch a column type from the schema: |
Yes, and that needs to be in our automation test suite with the other tests |
@Ocramius, you asked a question and I gave answer. What's the purpose of this comment? Do you want me to write a test for this? |
Yes, in @doctrine/doctrinecore we don't merge fixes without tests, unless they fix an already failing test |
Ok, I'm giving up on this. You guys can take it or leave it. I can't get it to pass some of your code checks. The code sniffer in travis is complaining about type hinting array items, I can't find any examples of type hinting array items. And it's complaining about the in_array() function, of which cannot find any documentation or reference to this error Also getting an error from appveyor about it not being able to find a driver. Not sure what to do about that, as I can get the phpunit test to pass locally. |
This means that at the top of the file, after the other
The syntax is something like |
Seems like travis failures is not related to PR. |
I believe this PR passes all the checks. I think it is being blocked by @morozov 's Change Request comment? |
I dismissed my request for changes. Please have someone else review the patch. |
Please kindly squash your commits together. If you don't, we'll try to remember to do it for you but it's best if you save us this trouble. How to do that?
|
tests/Doctrine/Tests/DBAL/Schema/PostgreSqlListTableForeignKeysTest.php
Outdated
Show resolved
Hide resolved
tests/Doctrine/Tests/DBAL/Schema/PostgreSqlListTableForeignKeysTest.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some conflicts
Github still complains about conflicts… can you please rebase? |
The build is failing because of coding style issues. You can try running |
I keep getting this error when trying to run phpcbf: |
@jwilson-cee run a |
Thanks, but getting the same error after re-running composer install. I'll just manually fix the code style. |
tests/Doctrine/Tests/DBAL/Schema/PostgreSqlListTableFunctionsTest.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is starting to look really good!
Please kindly squash your commits together. If you don't, we'll try to remember to do it for you but it's best if you save us this trouble.
How to do that?
git rebase -i origin/master
, assumingorigin
is a git remote that points to this repository, and not your fork. If you're not sure what your remotes are, rungit remote -vvv
, there should be your fork and the holy/reference/base/origin/whatever-you-call-it repository.- A window will show up with many lines, replace
pick
withfixup
on every line but the first one - Close your editor, git should do its magic, and you should end up with one commit
- Use
git push --force
to overwrite what you already push. Don't forget the--force
option otherwise git will try to merge both things together.
When doing so, please make sure to follow the contributing guide regarding the commit message. This PR is non-trivial, and that means the commit message should be high quality.
Issue doctrine#950: The cardinality error would happen when the schema wasn't prefixed in the $table parameter. As the subquery in the WHERE = clause would return more than one result if there was the same table name in two different schemas. (This is specific to postgres only.) This adds: - LIMIT 1 to the subquery of the WHERE = (SELECT ...) clause - A clearer parameter name $tableWithSchema and doc blocks to convey what's expected for this function - A deprecation message for when the schema is not included
b43423b
to
5d36b30
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- retarget needed
- remove
LIMIT 1
- throw a meaningful exception if and only if there is a crash
Looks like we still have to find an agreement on what to do
We're debating this internally, and will do the necessarily retargets for you when we agree. We're in the middle of changing workflows for Doctrine, hence the confusion, sorry for this. |
@greg0ire My reasoning is that I've dug into all the Because of this discovery, I believe it might be better to move this discussion to the #950 issue thread than continue in here, as this may warrant further discussion on the direction you want to take for this. And, because of this, it will probably be cleaner to start with a new branch, and let this one die. If you'd rather keep it in this branch/PR, I'll keep this open and put my findings (the SQL test code) in this comment thread. Thanks |
You can start afresh if you think it's best. I'm AFK this weekend though, so don't expect much more from me until Tuesday. |
Closing this PR as the fix for this needs further discussion (see issue #950) |
Fixed cardinality issue where subquery could return more than than one row in getListTableForeignKeysSQL function
Summary
The cardinality error would happen when the schema wasn't prefixed in the $table parameter. As the subquery in the
WHERE =
clause would return more than one result if there was the same table name in two different schemas. (This is specific to postgres only.)This adds:
LIMIT 1
to the subquery of theWHERE = (SELECT ...)
clause$tableWithSchema
and doc blocks to convey what's expected for this function