On Feb 17, 2010, at 9:19 AM, Manlio Perillo wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi.
> 
> I have found another limitation of SQLAlchemy, when handling joins.
> The code is here:
> http://paste.pocoo.org/show/179286/
> 
> I get:
> sqlalchemy.exc.ArgumentError: Can't determine join between 'Join object
> on Join object on content_types(159586732) and
> contents(159588044)(160166604) and content_article(159601292)' and
> 'categories'; tables have more than one foreign key constraint
> relationship between them. Please specify the 'onclause' of this join
> explicitly.
> 
> 
> However, again, a plain SQL NATURAL JOIN has no problems figuring out
> how to do the join.
> 
> How hard is to improve the util.join_condition function?

> 
> In the code I posted, it is rather obvious how to do the join, since
> only one of the two foreign key constraint in the `content_article`
> table should be used for the join with the `categories` table.
> Instead SQLAlchemy is considering *all* foreign key constraints, even
> the ones that don't involve the two tables being joined.

it definitely only considers foreign keys that join between the left and right 
sides.    if the left side is itself a join, all columns which reference or are 
referenced by the right are considered.   the difference with NATURAL JOIN is 
that it is specifically against the rightmost side of the left chain.    Feel 
free to implement this for join_condition assuming test coverage can be 
maintained.





> 
> 
> 
> Thanks  Manlio
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> 
> iEYEARECAAYFAkt7+vQACgkQscQJ24LbaUTWWgCgjz8lvMdXzJucUWzI1XMAOZV1
> pQ0AnRBmYousLdkM4fj+jNjxKchAlI2/
> =sve5
> -----END PGP SIGNATURE-----
> 
> -- 
> 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.
> 

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