Opened 12 years ago

Closed 12 years ago

#18014 closed Cleanup/optimization (fixed)

Remove rev_join_map from sql/query.py

Reported by: Anssi Kääriäinen Owned by: nobody
Component: Database layer (models, ORM) Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The sql.query.QuerySet.rev_join_map is used currently in two places of the query.py:

  1. In query.combine(). The information used there is available directly from alias_map
  2. In relabel_aliases as a fast path to join_map. However, one can just iterate through the join_map and relabel the aliases directly.

It is hard to see if the usage in 1. is actually currently correct or not: when combining queries the joins are re-added using _table_ name for the left hand side of the join (the thing we are joining into). I am pretty sure the correct way would be to do that using the existing lhs _alias_ so that the joins are added to the same previous join as in the original query.

While the cleanup doesn't promise much advancement, it would give a (really) small speedup to query cloning. Just getting rid of one variable is reason enough for removal I guess.

Attachments (1)

18014.diff (3.2 KB ) - added by Anssi Kääriäinen 12 years ago.

Download all attachments as: .zip

Change History (5)

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

The attached patch does the mentioned removal. I am actually pretty sure the rev_join_map usage in query.combine is broken: the intention is to use the left hand side table's alias, but rev_join_map has the table instead of the alias. All tests passed on SQLite3.

by Anssi Kääriäinen, 12 years ago

Attachment: 18014.diff added

comment:2 by Claude Paroz, 12 years ago

Has patch: set
Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization

comment:3 by Alex Gaynor, 12 years ago

Looks pretty reasonable to me, check in at your discretion!

comment:4 by Anssi Kääriäinen, 12 years ago

Resolution: fixed
Status: newclosed

In [17878]:

Fixed #18014 -- Removed rev_join_map from sql/query.py.

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