]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
hypothetical (failing) test for primary key selection of joins
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 23 May 2006 14:59:11 +0000 (14:59 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 23 May 2006 14:59:11 +0000 (14:59 +0000)
test/selectable.py

index aefef25e06944ee7e1f18d41b97ea157c94e9527..c1a3f28e5dcc13fff70ea971509fcb8b4de25ef2 100755 (executable)
@@ -25,6 +25,13 @@ table2 = Table('table2', db,
     redefine=True\r
 )\r
 \r
+table3 = Table('table3', db, \r
+    Column('col1', Integer, ForeignKey('table1.col1'), primary_key=True),\r
+    Column('col2', Integer),\r
+    Column('col3', String(20)),\r
+    redefine=True\r
+    )\r
+\r
 class SelectableTest(testbase.AssertMixin):\r
     def testtablealias(self):\r
         a = table.alias('a')\r
@@ -36,6 +43,17 @@ class SelectableTest(testbase.AssertMixin):
         print str(j)\r
         self.assert_(criterion.compare(j.onclause))\r
 \r
+    def testjoinpks(self):\r
+        a = join(table, table3)\r
+        b = join(table, table3, table.c.col1==table3.c.col2)\r
+        c = join(table, table3, table.c.col2==table3.c.col2)\r
+        d = join(table, table3, table.c.col2==table3.c.col1)\r
+        \r
+        self.assert_(a.primary_key==[table.c.col1])\r
+        self.assert_(b.primary_key==[table.c.col1, table3.c.col1])\r
+        self.assert_(c.primary_key==[table.c.col1, table3.c.col1])\r
+        self.assert_(d.primary_key==[table.c.col1, table3.c.col1])\r
+        \r
     def testjoin(self):\r
         a = join(table, table2)\r
         print str(a.select(use_labels=True))\r