diff options
author | mike bayer <mike_mp@zzzcomputing.com> | 2022-07-28 18:19:44 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@ci3.zzzcomputing.com> | 2022-07-28 18:19:44 +0000 |
commit | 9a8d039716068ded890e726ba344620907d86170 (patch) | |
tree | c04cd4c946a9fd7dcff5d8b1f39830c4d403e5cc /lib/sqlalchemy/sql/compiler.py | |
parent | 68a3374d5aae83b75b943b186802a6975e6b46fb (diff) | |
parent | 41656f830c41734063a9460d2800c74123837de6 (diff) | |
download | sqlalchemy-9a8d039716068ded890e726ba344620907d86170.tar.gz |
Merge "feat: add `drop constraint if exists` to compiler" into main
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
-rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 08b876e69..6d9d47388 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -5259,10 +5259,11 @@ class DDLCompiler(Compiled): "Can't emit DROP CONSTRAINT for constraint %r; " "it has no name" % drop.element ) - return "ALTER TABLE %s DROP CONSTRAINT %s%s" % ( + return "ALTER TABLE %s DROP CONSTRAINT %s%s%s" % ( self.preparer.format_table(drop.element.table), + "IF EXISTS " if drop.if_exists else "", formatted_name, - drop.cascade and " CASCADE" or "", + " CASCADE" if drop.cascade else "", ) def get_column_specification(self, column, **kwargs): |