-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
Fixed #34967 -- Fixed queryset crash when grouping by constants on SQLite < 3.39. #17468
Fixed #34967 -- Fixed queryset crash when grouping by constants on SQLite < 3.39. #17468
Conversation
0cf7b58
to
f7c0743
Compare
Looks like this fails if |
@shangxiao your second solution is definitely the good one. There's no point in grouping by constants and it's even harmful in the case of integer literal as that translates into unintended grouping by |
hi @charettes yeah I'm thinking perhaps even putting the 2nd solution behind a feature flag because I don't know how Oracle will respond to that given the older versions don't know what a "TRUE" is. |
buildbot test on oracle |
Buildbot, test on oracle |
buildbot, test on oracle. |
8a64f85
to
ace07c4
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.
@shangxiao Thanks 👍 I left two small suggestions.
nice I can squash things up and add Simon as co-author if you like |
…Lite < 3.39. On SQLite < 3.39, this forces a GROUP BY clause with a HAVING clause when no grouping is specified. Co-authored-by: Simon Charette <charette.s@gmail.com>
21e2643
to
b863c5f
Compare
No need, squashed & rebased. |
https://code.djangoproject.com/ticket/34967
The issue is only when
values()
is applied with a staticValue
, eg:qs.values(static=Value('static')).annotate(<some-aggregate>).filter(<on-aggregate>)
Postgres, MySQL (haven't tested Oracle) accept queries with HAVING yet no GROUP BY clause. The resulting behaviour is to consider the entire result (ie virtual table after where is applied) the group.
Equivalent behaviour would be to GROUP BY 'static' 🤷♂️ Forcing(see conversation below)Value
to return something fixes this (but at what cost? 🤔)