#18726: Combination of F() expression with query seems to confuse sql compiler's
table aliases
----------------------------------------------+--------------------
     Reporter:  bugs@…                        |      Owner:  nobody
         Type:  Bug                           |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  1.4
     Severity:  Normal                        |   Keywords:
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+--------------------
 Hi,

 I have a query that causes the sql compiler to output invalid sql. Running
 a query of the form (excuse the coarse anonymization):

 {{{#!python
 AThroughModel.objects.exclude ( foreignkeyfield_a__m2mfield_b__m2mfield_c
 = F ( "foreignkeyfield_x__foreignkeyfield_y__foreignkeyfield_z" ) )
 }}}

 this causes an exception along the lines of:

 {{{
 DatabaseError: missing FROM-clause entry for table "u4"
 LINE 1: ...) INNER JOIN "m2mfield_b_join_table_name" U5 ON (U4."id" = ...
 }}}

 Where AThroughModel is a model that's used as a "through" in an m2mfield
 from foreignkeyfield_x's model to foreignkeyfield_a's model.

 Interestingly, it works when you exchange the .exclude() with a .filter().

 This happens both on django 1.3.1 and 1.4.1 with a postgres backend &
 psycopg2.

 Again, sorry about the dumb anonymization, but my boss would be a bit
 funny about exposing model structure. A full (non) working test case might
 be a bit tricky as such.

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to