Code

Opened 11 months ago

Closed 11 months ago

Last modified 11 months ago

#20507 closed Bug (fixed)

SubqueryConstraint doesn't relabel aliases correctly

Reported by: akaariai Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

SubqueryConstraint (added in #19385) doesn't correctly handle relabeling of aliases. The problem is that SubqueryConstraint defines relabeled_clone(), but due to SubqueryConstraint being added directly to wherenode as children, not part of a children, the relabeled_clone() isn't ever called.

To trigger this bug one needs to do for example a double __in lookup (that is, lookup with __in=qs where the qs has a __in=qs2 lookup itself), or __in=qs + combine of query.

This can be fixed by adding clone() and relabel_aliases() methods to SubqueryConstraint.

This bug is present in 1.6-alpha-1.

Attachments (0)

Change History (2)

comment:1 Changed 11 months ago by Anssi Kääriäinen <akaariai@…>

  • Resolution set to fixed
  • Status changed from new to closed

In d467e117856a7fa6da5e90471144aaa82d822065:

Fixed #20507 -- SubqueryConstraint alias relabeling

The SubqueryConstraint defined relabeled_clone(), but that was never
called. Instead there is now clone() and relabel_aliases() methods for
SubqueryConstraint.

A related problem was that SubqueryConstraint didn't correctly use
quote_name_unless_alias() of the outer query. This resulted in failures
when running under PostgreSQL.

comment:2 Changed 11 months ago by Anssi Kääriäinen <akaariai@…>

In 37ea9f9c03b8ec4305ac978e85db653b432b9921:

Fixed #20507 -- SubqueryConstraint alias handling

MySQL should work now, too.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.