summaryrefslogtreecommitdiff
path: root/test/sql/test_metadata.py
diff options
context:
space:
mode:
authorJesse Bakker <github@jessebakker.com>2022-09-06 16:00:10 -0400
committermike bayer <mike_mp@zzzcomputing.com>2022-10-04 02:40:20 +0000
commitb6eed88ef4ebb3fd7035b4e366bf6653ebb26d15 (patch)
treee98e19d6fa7b236cf2fc7eed3ffc96c805b80667 /test/sql/test_metadata.py
parentd5905ccd7df000143194975f8f3d72fcef0672e3 (diff)
downloadsqlalchemy-b6eed88ef4ebb3fd7035b4e366bf6653ebb26d15.tar.gz
Make if_exists and if_not_exists flags on ddl statements match compiler
Added ``if_exists`` and ``if_not_exists`` parameters for all "Create" / "Drop" constructs including :class:`.CreateSequence`, :class:`.DropSequence`, :class:`.CreateIndex`, :class:`.DropIndex`, etc. allowing generic "IF EXISTS" / "IF NOT EXISTS" phrases to be rendered within DDL. Pull request courtesy Jesse Bakker. Fixes: #7354 Closes: #8492 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8492 Pull-request-sha: d107c6ce553bd430111607815f5b3938ffc4770c Change-Id: I367e57b2d9216f5180bcc44e86ca6f3dc794e5ca
Diffstat (limited to 'test/sql/test_metadata.py')
-rw-r--r--test/sql/test_metadata.py8
1 files changed, 8 insertions, 0 deletions
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",
)