On May 27, 2008, at 3:23 PM, Moshe C. wrote:

>
> 2) Uncommenting the join in line ##2 causes the following exception
> when trying to print the query:
> raise exceptions.InvalidRequestError("Select statement '%s' returned
> no FROM clauses due to auto-correlation; specify correlate(<tables>)
> to control correlation manually." % self)

this is due to a bug in 0.4 which is fixed in version 0.5.  The join  
to the "Many" table is bleeding into the subquery produced by  
One.many.any(), which attempts to correlate all FROM clauses within it  
("one_table" and "many_table") to the enclosing select.   In 0.4 you  
can work around this in most cases by issuing  
One.many.any(whatever).correlate(one_table) to force it to correlate  
only to the "one" table which is the desired effect.  Alternatively  
you can join on an aliased table by saying query.join('many',  
aliased=True) which will also separate the join to "many" from the  
subquery within the any().

>
>
> 3) This is the reason I decided to use correlate(). When I added
> correlate(Many) in line ##1 like this:
> myquery =
> session 
> .query(One).filter(One.many.any(Many.c.id==333).correlate(Many))
> ## 1
>
> I got the following exception when tryint to print the query:
> AttributeError: type object 'Many' has no attribute '_cloned_set'
>
>
> What is my mistake?

"Many" is a class.  the correlate() method on select() only accepts  
Table objects.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to