HTTPS clone URL
Subversion checkout URL
Please sign in to comment.
Fixed #10790 -- Refactored sql.Query.setup_joins()
This is a rather large refactoring. The "lookup traversal" code was splitted out from the setup_joins. There is now names_to_path() method which does the lookup traveling, the actual work of setup_joins() is calling names_to_path() and then adding the joins found into the query. As a side effect it was possible to remove the "process_extra" functionality used by genric relations. This never worked for left joins. Now the extra restriction is appended directly to the join condition instead of the where clause. To generate the extra condition we need to have the join field available in the compiler. This has the side-effect that we need more ugly code in Query.__getstate__ and __setstate__ as Field objects aren't pickleable. The join trimming code got a big change - now we trim all direct joins and never trim reverse joins. This also fixes the problem in #10790 which was join trimming in null filter cases.
- Loading branch information...
Showing with 564 additions and 268 deletions.
- +8 −18 django/contrib/contenttypes/generic.py
- +18 −10 django/db/models/sql/compiler.py
- +9 −2 django/db/models/sql/constants.py
- +2 −2 django/db/models/sql/expressions.py
- +233 −230 django/db/models/sql/query.py
- +4 −0 tests/regressiontests/aggregation_regress/tests.py
- +22 −1 tests/regressiontests/queries/models.py
- +268 −5 tests/regressiontests/queries/tests.py