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
Negation with .self_group() #4320
Comments
Michael Bayer (@zzzeek) wrote: same question, how did you come across this? what are you trying to achieve (briefly) ? |
Michael Bayer (@zzzeek) wrote: the "=0" is coming out for backends that don't have the concept of "native boolean", which means among other things they don't like specifying a column as a boolean, such as, "SELECT * FROM table WHERE x" or "SELECT * FROM table WHERE NOT x", hence SQLAlchemy adds "=1" or "=0" to express the integer comparison explicitly, as these databases use integer values 1/0 to represent boolean. The original issue in #3969 was that the parenthesis were getting lost. However here, the parenthesis are maintained. On the two backends that are most prominently non-native boolean, I can't reproduce any problem: SQLite:
MySQL / MariaDB:
so while the expression is visually unappealing, it works fine. Can you provide more detail how this behavior is impacting what you are trying to do ? |
Alana Pradhan wrote: Thank you for getting back to me. I think then the issue is with Oracle (v12c 12.1)? When I try to run a query using that syntax, I get a syntax error: ORA-00933: SQL command not properly ended
|
Michael Bayer (@zzzeek) wrote: OK...and why are you calling self_group() explicitly? |
Alana Pradhan wrote: So I might be using the ORM API incorrectly, but I always call |
Michael Bayer (@zzzeek) wrote: OK. I'd like to see if this can be fixed though a quick solution is eluding me. But you probably don't need to call self_group() as parenthesization is added automatically based on precedence rules. |
Alana Pradhan wrote: Awesome. Thank you for letting me know about the parentheses being automatically added. I do see that in my code and was able to remove the .self_group() call. (Also, just wanted to say that I'm a huge fan of sqlalchemy and appreciate all the work you've done as well as the contribution to the community) |
Michael Bayer (@zzzeek) wrote: a proposal is up at https://gerrit.sqlalchemy.org/#/c/zzzeek/sqlalchemy/+/841. not sure if I want this backported to 1.2 or not but that is the plan at the moment. |
Michael Bayer (@zzzeek) wrote: passed on the first run will put it in 1.2 also |
Michael Bayer (@zzzeek) wrote: Add concept of "implicit boolean", treat as native Fixed issue that is closely related to 🎫 Fixes: #4320 → 462ccd9 |
Changes by Michael Bayer (@zzzeek):
|
Michael Bayer (@zzzeek) wrote: Add concept of "implicit boolean", treat as native Fixed issue that is closely related to 🎫 Fixes: #4320 → 7b53d99 |
Migrated issue, originally created by Alana Pradhan
I think this bug is an extension of https://bitbucket.org/zzzeek/sqlalchemy/issues/3969/negation-of-labeled-element
I hit this bug in 1.2.10 when I add
.self_group()
to the or_ expression:The text was updated successfully, but these errors were encountered: