summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/sql/test_constraints.py14
-rw-r--r--test/sql/test_metadata.py8
-rw-r--r--test/sql/test_sequences.py10
3 files changed, 32 insertions, 0 deletions
diff --git a/test/sql/test_constraints.py b/test/sql/test_constraints.py
index 462667bed..b1b731d66 100644
--- a/test/sql/test_constraints.py
+++ b/test/sql/test_constraints.py
@@ -765,6 +765,14 @@ class ConstraintCompilationTest(fixtures.TestBase, AssertsCompiledSQL):
i = Index("xyz", t.c.x)
self.assert_compile(schema.CreateIndex(i), "CREATE INDEX xyz ON t (x)")
+ def test_create_index_if_not_exists(self):
+ t = Table("t", MetaData(), Column("x", Integer))
+ i = Index("xyz", t.c.x)
+ self.assert_compile(
+ schema.CreateIndex(i, if_not_exists=True),
+ "CREATE INDEX IF NOT EXISTS xyz ON t (x)",
+ )
+
def test_drop_index_plain_unattached(self):
self.assert_compile(
schema.DropIndex(Index(name="xyz")), "DROP INDEX xyz"
@@ -775,6 +783,12 @@ class ConstraintCompilationTest(fixtures.TestBase, AssertsCompiledSQL):
schema.DropIndex(Index(name="xyz")), "DROP INDEX xyz"
)
+ def test_drop_index_if_exists(self):
+ self.assert_compile(
+ schema.DropIndex(Index(name="xyz"), if_exists=True),
+ "DROP INDEX IF EXISTS xyz",
+ )
+
def test_create_index_schema(self):
t = Table("t", MetaData(), Column("x", Integer), schema="foo")
i = Index("xyz", t.c.x)
diff --git a/test/sql/test_metadata.py b/test/sql/test_metadata.py
index 38255f977..6d93cb234 100644
--- a/test/sql/test_metadata.py
+++ b/test/sql/test_metadata.py
@@ -2621,9 +2621,17 @@ class SchemaTest(fixtures.TestBase, AssertsCompiledSQL):
schema.CreateSchema("sa_schema"), "CREATE SCHEMA sa_schema"
)
self.assert_compile(
+ schema.CreateSchema("sa_schema", if_not_exists=True),
+ "CREATE SCHEMA IF NOT EXISTS sa_schema",
+ )
+ self.assert_compile(
schema.DropSchema("sa_schema"), "DROP SCHEMA sa_schema"
)
self.assert_compile(
+ schema.DropSchema("sa_schema", if_exists=True),
+ "DROP SCHEMA IF EXISTS sa_schema",
+ )
+ self.assert_compile(
schema.DropSchema("sa_schema", cascade=True),
"DROP SCHEMA sa_schema CASCADE",
)
diff --git a/test/sql/test_sequences.py b/test/sql/test_sequences.py
index 19f95c661..457aeb960 100644
--- a/test/sql/test_sequences.py
+++ b/test/sql/test_sequences.py
@@ -93,9 +93,19 @@ class SequenceDDLTest(fixtures.TestBase, testing.AssertsCompiledSQL):
)
self.assert_compile(
+ CreateSequence(Sequence("foo_seq"), if_not_exists=True),
+ "CREATE SEQUENCE IF NOT EXISTS foo_seq START WITH 1",
+ )
+
+ self.assert_compile(
DropSequence(Sequence("foo_seq")), "DROP SEQUENCE foo_seq"
)
+ self.assert_compile(
+ DropSequence(Sequence("foo_seq"), if_exists=True),
+ "DROP SEQUENCE IF EXISTS foo_seq",
+ )
+
class SequenceExecTest(fixtures.TestBase):
__requires__ = ("sequences",)