On Apr 8, 2011, at 7:08 AM, Aleksander Siewierski wrote:

> Thanks for response,
> 
> TaskIntro table is defined as:
> 
> Table(
>        'task_intros',
>        METADATA,
> 
>        Column('id', Integer, primary_key=True),
>        ...
>        Column('redirect_rule_id', Integer,
> ForeignKey('redirect_rules.id'), nullable=True),
>        mysql_engine='InnoDB',
>        mysql_charset='utf8'
>    )
> 
> 
> and query defined in function above is taken as
> SESSION.query(TaskIntro) and then I just call method all().
> 
> So, from table definition and redirect_rule_id foreign key you can
> see, that this is impossible that more than one redirect_rule row will
> be matched to task_intro.


The contains_eager() call assumes you've added RedirectRule to your join() 
condition (e.g. as in 
http://www.sqlalchemy.org/docs/orm/loading.html#routing-explicit-joins-statements-into-eagerly-loaded-collections
 ) , adds all the columns from RedirectRule to the columns clause of the SELECT 
in order to receive them, but since you didn't actually join to RedirectRule it 
gets added to the FROM clause; you get a cartesian product of all 
RedirectRule/TaskIntro rows and that's the cause of the error.     You can 
diagnose issues like these quickly if you set echo='debug' on your 
create_engine() to view the SQL + rows received.


-- 
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