-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
DDC-3063: Unexpected behavior with 'WHERE NOT IN' and empty array #3835
Comments
Comment created by @Ocramius: This is a simple misunderstanding of how SQL |
Comment created by timstamp: You're right that its invalid SQL, but this is DQL. In SQL this would raise an error, in DQL it says nothing and returns nothing. Isnt there a way to check if a statement has caused this error? |
Comment created by @Ocramius: [~timstamp] yeah, when using |
Comment created by @deeky666: It's still weird that no error is raised by that. [~timstamp] can you check what SQL is generated by your query? |
Comment created by @deeky666: Hehe I think I got the problem. It might be DBAL related. See: https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/SQLParserUtils.php#L140 Looks like the implementing person did that by intention but don't ask me why. |
Comment created by @Ocramius: Thats to avoid having an SQL statement like Indeed, the |
Comment created by @deeky666: Just wondering if that kind of implementation isn't changing expectations because it looks like IN(NULL) will select all NULL rows then, even though this is not explicitly requested by the user. I don't care really TBH but this behaviour is not very transparent to the user. Personally I would like to see an error instead... Then at least I know what's going on and can fix that by additional checks instead. |
Comment created by @Ocramius: Makes sense. Re-opening. |
Comment created by @deeky666: The question is if we can change this behaviour without breaking applications that rely on the current one. Because changing the code to throw an error breaks applications that insist on returning 0 rows for an empty array. I don't know what rules apply here concerning BC. What do you think [~ocramius]? |
Comment created by @Ocramius: [~deeky] existing apps should do following anyway:
If they are not, that's most likely a bug in their codebase. |
Comment created by @deeky666: Agree. Was just wondering about what we can expect and what we can't expect. |
Comment created by @guilhermeblanco: [~deeky666] feel free to patch DBAL. |
Comment created by timstamp: [~guilhermeblanco] shouldn't both these use cases throw an exception, as both cases in MySQL would return an error? |
See PR 7108. |
Still a problem that i'm continuously bumping into. Ugly solutions do fix it but are only temporary. |
Hit the same cause. When calling |
Just check that an empty array is not used, or initialize it with an element, for example, a zero |
@KhanMaytok I suggest helping @jackdpeterson with finishing up their fix. |
+1 |
Jira issue originally created by user timstamp:
I tried to set version to 2.4.0 but was prevented.
Assume the set 'n' contains 10 records, all with id > 0.
The text was updated successfully, but these errors were encountered: