[Django] #24020: Use expressions in ORM internals

36 views
Skip to first unread message

Django

unread,
Dec 18, 2014, 3:57:07 AM12/18/14
to django-...@googlegroups.com
#24020: Use expressions in ORM internals
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: master
Component: Database | Keywords:
layer (models, ORM) | Has patch: 1
Severity: Normal | Needs tests: 0
Triage Stage: Accepted | Easy pickings: 0
Needs documentation: 0 |
Patch needs improvement: 1 |
UI/UX: 0 |
-------------------------------------+-------------------------------------
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/24020>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 18, 2014, 3:59:54 AM12/18/14
to django-...@googlegroups.com
#24020: Use expressions in ORM internals
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: master
Component: Database layer | Resolution:
(models, ORM) | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: | Patch needs improvement: 1
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by akaariai):

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/24020#comment:1>

Django

unread,
Dec 18, 2014, 8:01:28 AM12/18/14
to django-...@googlegroups.com
#24020: Use expressions in ORM internals
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: master
Component: Database layer | Resolution:
(models, ORM) | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: | Patch needs improvement: 1
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by Carl Meyer <carl@…>):

In [changeset:"4a2a433e7daca1e1797b7b34d30d49ad4e09791c"]:
{{{
#!CommitTicketReference repository=""
revision="4a2a433e7daca1e1797b7b34d30d49ad4e09791c"
Refs #24020 -- return expressions from get_group_by_cols()
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24020#comment:2>

Django

unread,
Dec 29, 2014, 5:42:28 AM12/29/14
to django-...@googlegroups.com
#24020: Use expressions in ORM internals
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: akaariai
Type: | Status: assigned
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: 1.8-alpha | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by akaariai):

* keywords: => 1.8-alpha
* owner: nobody => akaariai
* status: new => assigned


Comment:

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

--
Ticket URL: <https://code.djangoproject.com/ticket/24020#comment:3>

Django

unread,
Jan 8, 2015, 10:38:53 AM1/8/15
to django-...@googlegroups.com
#24020: Use expressions in ORM internals
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: akaariai
Type: | Status: assigned
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: 1.8-alpha | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/24020#comment:4>

Django

unread,
Jan 8, 2015, 2:15:52 PM1/8/15
to django-...@googlegroups.com
#24020: Use expressions in ORM internals
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: akaariai
Type: | Status: closed

Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed

Keywords: 1.8-alpha | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"0c7633178fa9410f102e4708cef979b873bccb76"]:
{{{
#!CommitTicketReference repository=""
revision="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.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24020#comment:5>

Django

unread,
Mar 31, 2022, 4:55:51 AM3/31/22
to django-...@googlegroups.com
#24020: Use expressions in ORM internals
-------------------------------------+-------------------------------------
Reporter: Anssi Kääriäinen | Owner: Anssi
Type: | Kääriäinen
Cleanup/optimization | Status: closed
Component: Database layer | Version: dev

(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: 1.8-alpha | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"0a3c6fe6b2c43b0bb90cb9df3840dcb70edc22a1" 0a3c6fe6]:
{{{
#!CommitTicketReference repository=""
revision="0a3c6fe6b2c43b0bb90cb9df3840dcb70edc22a1"
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().
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24020#comment:6>

Reply all
Reply to author
Forward
0 new messages