Opened 10 years ago

Closed 10 years ago

Last modified 3 years ago

#24020 closed Cleanup/optimization (fixed)

Use expressions in ORM internals

Reported by: Anssi Kääriäinen Owned by: Anssi Kääriäinen
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords: 1.8-alpha
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

We should use expressions instead of tuples of form (alias, column, field) when calculating the select, order_by and group by clauses of the ORM. The WHERE clause already uses lookups, and joins were made to use Join classes. This would finalize usage of expression like objects throughout the query compiling process.

Change History (6)

comment:1 by Anssi Kääriäinen, 10 years ago

The implementation in pull request 3669 will also change the way select_related is handled in the ORM. This should fix at least tickets #21204 and #23270. There are likely other older tickets which should be fixed, too.

comment:2 by Carl Meyer <carl@…>, 10 years ago

In 4a2a433e7daca1e1797b7b34d30d49ad4e09791c:

Refs #24020 -- return expressions from get_group_by_cols()

comment:3 by Anssi Kääriäinen, 10 years ago

Keywords: 1.8-alpha added
Owner: changed from nobody to Anssi Kääriäinen
Status: newassigned

I'd like to get this into 1.8. I don't think there is that much to do any more.

comment:4 by Tim Graham, 10 years ago

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:5 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: assignedclosed

In 0c7633178fa9410f102e4708cef979b873bccb76:

Fixed #24020 -- Refactored SQL compiler to use expressions

Refactored compiler SELECT, GROUP BY and ORDER BY generation.
While there, also refactored select_related() implementation
(get_cached_row() and get_klass_info() are now gone!).

Made get_db_converters() method work on expressions instead of
internal_type. This allows the backend converters to target
specific expressions if need be.

Added query.context, this can be used to set per-query state.

Also changed the signature of database converters. They now accept
context as an argument.

comment:6 by Mariusz Felisiak <felisiak.mariusz@…>, 3 years ago

In 0a3c6fe6:

Refs #24020 -- Removed redundant Query.get_loaded_field_names().

get_loaded_field_names() is no longer called in multiple places
(see 0c7633178fa9410f102e4708cef979b873bccb76) and it's redundant
with SQLCompiler.deferred_to_columns().

Note: See TracTickets for help on using tickets.
Back to Top