-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Michael Bayer ha scritto: > [...] > Since we are speaking about _match_primaries, I'm curious to know why > the implementation is: > > def _match_primaries(self, primary, secondary): > global sql_util > if not sql_util: > from sqlalchemy.sql import util as sql_util > return sql_util.join_condition(primary, secondary) > > What is the need for a sql_util to be global? > >> that pattern is used when there is a circular module import between two >> modules. the global + boolean is to avoid repeated calls to "import". >
Ok, thanks. I have never seen this pattern in use. If the import is done inside a function, usually there are no problems with circular module import. > >>>>> just ask "well is this particular foreign key the rightmost join on >>>>> the left side" and then its good. >>>> > > Non sure to understand what you have in mind, here. > > Do you mean that the checks: > `if len(crit) == 0` and `len(constraints) > 1` should not be done by the > util.join_condition, and instead: > > 1) `_match_primaries` method will call `util.join_condition`, using the > rightmost join on the left side (as in my patch) > 2) if len(crit) == 0, then it will call `util.join_condition` again, but > this time using the left side of the join, as is > >> that is pretty much what I mean. if the left side is a join, then call >> join_condition with the rightmost side of the left first, if nothing >> returned, call with the full left side. > Ok. If no one else is interested in this feature I can try to write a patch, with tests included. Manlio -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkt/BoMACgkQscQJ24LbaURR6wCdEdo5mitZcabEArqPe2BQV1Ez EY0An3YFxGgWE8LcHnHi6aqYlxoeKfPd =+p49 -----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 sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.