]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- add an explicit test for sequences "optional"
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 6 Feb 2013 21:24:38 +0000 (16:24 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 6 Feb 2013 21:24:38 +0000 (16:24 -0500)
lib/sqlalchemy/testing/requirements.py
lib/sqlalchemy/testing/suite/test_sequence.py

index f7d00afb2933b18ca2e9f26154bce98ac2b3ddf7..e44a333beb48e6fabca2c8fda4d50bd70daa1b20 100644 (file)
@@ -155,7 +155,17 @@ class SuiteRequirements(Requirements):
 
         return exclusions.only_if([
                 lambda: self.config.db.dialect.supports_sequences
-            ], "no SEQUENCE support")
+            ], "no sequence support")
+
+    @property
+    def sequences_optional(self):
+        """Target database supports sequences, but also optionally
+        as a means of generating new PK values."""
+
+        return exclusions.only_if([
+                lambda: self.config.db.dialect.supports_sequences and \
+                    self.config.db.dialect.sequences_optional
+            ], "no sequence support, or sequences not optional")
 
     @property
     def reflects_pk_names(self):
index 0b60aa5b7c74c1ccbef2336b258b2905fc2bb2d9..366d509cc36c9decc1a53975d72cb058499fc730 100644 (file)
@@ -18,6 +18,12 @@ class SequenceTest(fixtures.TablesTest):
                 Column('data', String(50))
             )
 
+        Table('seq_opt_pk', metadata,
+                Column('id', Integer, Sequence('tab_id_seq', optional=True),
+                                                primary_key=True),
+                Column('data', String(50))
+            )
+
     def test_insert_roundtrip(self):
         config.db.execute(
             self.tables.seq_pk.insert(),
@@ -43,6 +49,16 @@ class SequenceTest(fixtures.TablesTest):
             r, 1
         )
 
+    @requirements.sequences_optional
+    def test_optional_seq(self):
+        r = config.db.execute(
+            self.tables.seq_opt_pk.insert(),
+            data="some data"
+        )
+        eq_(
+            r.inserted_primary_key,
+            [1]
+        )
 
 
     def _assert_round_trip(self, table, conn):