diff options
Diffstat (limited to 'test/sql/test_identity_column.py')
| -rw-r--r-- | test/sql/test_identity_column.py | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/test/sql/test_identity_column.py b/test/sql/test_identity_column.py index 3ac97db92..1ce15f38c 100644 --- a/test/sql/test_identity_column.py +++ b/test/sql/test_identity_column.py @@ -102,7 +102,7 @@ class _IdentityDDLFixture(testing.AssertsCompiledSQL): CreateTable(t), "CREATE TABLE foo_table (" "foo INTEGER GENERATED ALWAYS AS IDENTITY (START " - "WITH 3) NOT NULL, UNIQUE (foo))", + "WITH 3), UNIQUE (foo))", ) def test_autoincrement_true(self): @@ -120,10 +120,41 @@ class _IdentityDDLFixture(testing.AssertsCompiledSQL): self.assert_compile( CreateTable(t), "CREATE TABLE foo_table (" - "foo INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 3) NOT NULL" + "foo INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 3)" ", PRIMARY KEY (foo))", ) + def test_nullable_kwarg(self): + t = Table( + "t", + MetaData(), + Column("a", Integer(), Identity(), nullable=False), + Column("b", Integer(), Identity(), nullable=True), + Column("c", Integer(), Identity()), + ) + + is_(t.c.a.nullable, False) + is_(t.c.b.nullable, True) + is_(t.c.c.nullable, False) + + nullable = "" + if getattr(self, "__dialect__", None) != "default" and testing.against( + "postgresql" + ): + nullable = " NULL" + + self.assert_compile( + CreateTable(t), + ( + "CREATE TABLE t (" + "a INTEGER GENERATED BY DEFAULT AS IDENTITY, " + "b INTEGER GENERATED BY DEFAULT AS IDENTITY%s, " + "c INTEGER GENERATED BY DEFAULT AS IDENTITY" + ")" + ) + % nullable, + ) + class IdentityDDL(_IdentityDDLFixture, fixtures.TestBase): # this uses the connection dialect @@ -167,7 +198,7 @@ class NotSupportingIdentityDDL(testing.AssertsCompiledSQL, fixtures.TestBase): Column("foo", Integer(), Identity("always", start=3)), ) self.assert_compile( - CreateTable(t), "CREATE TABLE foo_table (foo INTEGER)" + CreateTable(t), "CREATE TABLE foo_table (foo INTEGER NOT NULL)" ) |
