]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- fixed bug where selectable.corresponding_column(selectable.c.col)
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 6 Jun 2007 23:37:18 +0000 (23:37 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 6 Jun 2007 23:37:18 +0000 (23:37 +0000)
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]

CHANGES
lib/sqlalchemy/sql.py
test/sql/selectable.py

diff --git a/CHANGES b/CHANGES
index fa98520c858b39f42569447ad9c1dcff1a849f0f..f074b27f753ee9554cb9c38e325574994c0e7f41 100644 (file)
--- 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]
     
index fb32c0f07e85d446222e63f657fd7d58cd233449..3a8a27d67e408dba8e648ee2b5e57635e35448b0 100644 (file)
@@ -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
index cd434a18450187a9c5ae7a9e6bf2bb3421863d41..221d8430c409522cfd23bbdb24defe2c729eae61 100755 (executable)
@@ -27,6 +27,13 @@ table2 = Table('table2', db,
 )\r
 \r
 class SelectableTest(testbase.AssertMixin):\r
+    def testjoinagainstjoin(self):\r
+        j  = outerjoin(table, table2, table.c.col1==table2.c.col2)\r
+        jj = select([ table.c.col1.label('bar_col1')],from_obj=[j]).alias('foo')\r
+        jjj = join(table, jj, table.c.col1==jj.c.bar_col1)\r
+        assert jjj.corresponding_column(jjj.c.table1_col1) is jjj.c.table1_col1\r
+        \r
+        \r
     def testtablealias(self):\r
         a = table.alias('a')\r
         \r