From: Mike Bayer Date: Wed, 6 Jun 2007 23:37:18 +0000 (+0000) Subject: - fixed bug where selectable.corresponding_column(selectable.c.col) X-Git-Tag: rel_0_3_9~89 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a74da6d21e7f5f2dd31dbaa8bc6cbf11e165360e;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - fixed bug where selectable.corresponding_column(selectable.c.col) would not return selectable.c.col, if the selectable is a join of a table and another join involving the same table. messed up ORM decision making [ticket:593] --- diff --git a/CHANGES b/CHANGES index fa98520c85..f074b27f75 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,10 @@ - sql - long-identifier detection fixed to use > rather than >= for max ident length [ticket:589] + - fixed bug where selectable.corresponding_column(selectable.c.col) + would not return selectable.c.col, if the selectable is a join + of a table and another join involving the same table. messed + up ORM decision making [ticket:593] - mysql - added 'fields' to reserved words [ticket:590] diff --git a/lib/sqlalchemy/sql.py b/lib/sqlalchemy/sql.py index fb32c0f07e..3a8a27d67e 100644 --- a/lib/sqlalchemy/sql.py +++ b/lib/sqlalchemy/sql.py @@ -1670,7 +1670,9 @@ class FromClause(Selectable): it merely shares a common anscestor with one of the exported columns of this ``FromClause``. """ - + if column in self.c: + return column + if require_embedded and column not in util.Set(self._get_all_embedded_columns()): if not raiseerr: return None diff --git a/test/sql/selectable.py b/test/sql/selectable.py index cd434a1845..221d8430c4 100755 --- a/test/sql/selectable.py +++ b/test/sql/selectable.py @@ -27,6 +27,13 @@ table2 = Table('table2', db, ) class SelectableTest(testbase.AssertMixin): + def testjoinagainstjoin(self): + j = outerjoin(table, table2, table.c.col1==table2.c.col2) + jj = select([ table.c.col1.label('bar_col1')],from_obj=[j]).alias('foo') + jjj = join(table, jj, table.c.col1==jj.c.bar_col1) + assert jjj.corresponding_column(jjj.c.table1_col1) is jjj.c.table1_col1 + + def testtablealias(self): a = table.alias('a')