#32717: Incorrect SQL generation filtering OR-combined queries
-------------------------------------+-------------------------------------
Reporter: Shaheed Haque | Owner: Simon
| Charette
Type: Bug | Status: assigned
Component: Database layer | Version: 3.2
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Simon Charette):
> I'm not qualified to speak to most of this, but I'm wanted to check if
"we should prevent Query.combine from ever generating queries with root
Where(connector='OR')" means that the original OR'd query I wrote would
not be supported?
You queries would still be supported, it's more of how internal data
structures are used under the hood. Basically doing a `<QuerySet> |
<QuerySet>` is the only circumstances in the ORM where the returned
`QuerySet.query`, which is an instance of `sql.Query`, will have a
`.where` property, which is an instance of `sql.where.Where`, with a
`.connector == 'OR'` instead of `AND`. What I'm proposing we do here is
that instead of having `query.where.connector` be of the `(connector='OR',
nodes=[jurisdiction = 'GB', ...])` form we ensure that it's always nested
in a top-level `AND` instead so `(connector='AND', nodes=[(connector='OR',
nodes=[jurisdiction = 'GB', ...])])`.
Not totally necessary as the above patch that adjusts the ''optimization''
should address the issue, it'd be great if you could confirm it does, but
it does make the behaviour of `Query.combine` more in line with the
heavily tested paths the ORM usually takes.
--
Ticket URL: <https://code.djangoproject.com/ticket/32717#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/070.0b11f0993df821077a943056e9dde840%40djangoproject.com.