-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Michael Bayer ha scritto:
>
> On Feb 18, 2010, at 11:55 AM, Manlio Perillo wrote:
>
> Michael Bayer ha scritto:
>>>> [...]
>>>>> so what I had in mind is that, if its given a join as the left side,
>>>>> it just does the "natural" thing, i.e. joins to the right.
>>>>> If the "natural" join isn't available, then it does its usual
>>>>> search through the whole thing.
>
Here is another tentative patch.
Manlio
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkuEBiAACgkQscQJ24LbaUTzDQCfSSJBXe9LzQvKFcDva3oqojxp
WvQAn2k0Ykdn3hh1mmfFSg3gTOx1okPQ
=TiLH
-----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.
diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py
--- a/lib/sqlalchemy/sql/expression.py
+++ b/lib/sqlalchemy/sql/expression.py
@@ -2820,7 +2820,16 @@
global sql_util
if not sql_util:
from sqlalchemy.sql import util as sql_util
- return sql_util.join_condition(primary, secondary)
+
+ # First try the natural join
+ left = primary
+ while isinstance(left, Join):
+ left = left.right
+
+ try:
+ return sql_util.join_condition(left, secondary)
+ except exc.ArgumentError:
+ return sql_util.join_condition(primary, secondary)
def select(self, whereclause=None, fold_equivalents=False, **kwargs):
"""Create a :class:`Select` from this :class:`Join`.