Opened 5 years ago

Closed 5 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: master
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 (5)

comment:1 Changed 5 years ago by Anssi Kääriäinen

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 Changed 5 years ago by Carl Meyer <carl@…>

In 4a2a433e7daca1e1797b7b34d30d49ad4e09791c:

Refs #24020 -- return expressions from get_group_by_cols()

comment:3 Changed 5 years ago by Anssi Kääriäinen

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 Changed 5 years ago by Tim Graham

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

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

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.

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