diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2019-10-14 19:22:47 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@bbpush.zzzcomputing.com> | 2019-10-14 19:22:47 +0000 |
| commit | 567ee8d6a90a150e5079fc6d1cdad2734172e2e7 (patch) | |
| tree | 9a9ececeadd57497700169761f75c08b367fd840 /lib/sqlalchemy/sql/compiler.py | |
| parent | ea8856e8b0fc2ca41a0e410161a25d70d919721c (diff) | |
| parent | 41dc71ad2fc1963a44e5f308f53aed6b8d7d662a (diff) | |
| download | sqlalchemy-567ee8d6a90a150e5079fc6d1cdad2734172e2e7.tar.gz | |
Merge "Use separate label generator for column_label naming convention"
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
| -rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index c6c30629d..5ecec7d6c 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -3022,6 +3022,10 @@ class DDLCompiler(Compiled): text = "CREATE " if index.unique: text += "UNIQUE " + if index.name is None: + raise exc.CompileError( + "CREATE INDEX requires that the index have a name" + ) text += "INDEX %s ON %s (%s)" % ( self._prepared_index_name(index, include_schema=include_schema), preparer.format_table( @@ -3038,6 +3042,11 @@ class DDLCompiler(Compiled): def visit_drop_index(self, drop): index = drop.element + + if index.name is None: + raise exc.CompileError( + "DROP INDEX requires that the index have a name" + ) return "\nDROP INDEX " + self._prepared_index_name( index, include_schema=True ) @@ -3251,7 +3260,8 @@ class DDLCompiler(Compiled): text = "" if constraint.name is not None: formatted_name = self.preparer.format_constraint(constraint) - text += "CONSTRAINT %s " % formatted_name + if formatted_name is not None: + text += "CONSTRAINT %s " % formatted_name text += "UNIQUE (%s)" % ( ", ".join(self.preparer.quote(c.name) for c in constraint) ) |
