Commits

Mike Bayer committed 4c1d938

tests for FK/autoincrement selection

Comments (0)

Files changed (1)

test/sql/test_defaults.py

         )
         assert t._autoincrement_column is None
 
+    def test_autoincrement_ignore_fk(self):
+        m = MetaData()
+        y = Table('y', m,
+            Column('id', Integer(), primary_key=True)
+        )
+        x = Table('x', m,
+            Column('id', Integer(), 
+                ForeignKey('y.id'), 
+                autoincrement="ignore_fk", primary_key=True)
+        )
+        assert x._autoincrement_column is x.c.id
+
+    def test_autoincrement_fk_disqualifies(self):
+        m = MetaData()
+        y = Table('y', m,
+            Column('id', Integer(), primary_key=True)
+        )
+        x = Table('x', m,
+            Column('id', Integer(), 
+                ForeignKey('y.id'), 
+                primary_key=True)
+        )
+        assert x._autoincrement_column is None
+
     @testing.fails_on('sqlite', 'FIXME: unknown')
     def test_non_autoincrement(self):
         # sqlite INT primary keys can be non-unique! (only for ints)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.