summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/compiler.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-10-13 23:02:22 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2019-10-13 23:02:22 -0400
commit8a55fb6017b01c5b7503be2bedfa82b9663f8a94 (patch)
tree8bb6b6bb67d82ba7b4fd92400633e520b2cd401b /lib/sqlalchemy/sql/compiler.py
parent6b2875eba531a0b879ec345ec85fae00f522ff03 (diff)
downloadsqlalchemy-8a55fb6017b01c5b7503be2bedfa82b9663f8a94.tar.gz
Add _alembic_quote method to format_constraint()
Alembic needs a portable way of getting at the name of an index without quoting being applied. As we would like the indexes created by the Column index=True flag to support deferred index names, supply a function that delivers this for Alembic without it having to dig too deeply into the internals. the _alembic_quote flag may be made public at a later time, however as we've been through many quoting flags that are difficult to get rid of, try to be conservative to start. Change-Id: I184adaeae26c2e75093aaea5ebe01a3815cadb08
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
-rw-r--r--lib/sqlalchemy/sql/compiler.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py
index 453ff56d2..c6c30629d 100644
--- a/lib/sqlalchemy/sql/compiler.py
+++ b/lib/sqlalchemy/sql/compiler.py
@@ -3698,7 +3698,7 @@ class IdentifierPreparer(object):
return ident
@util.dependencies("sqlalchemy.sql.naming")
- def format_constraint(self, naming, constraint):
+ def format_constraint(self, naming, constraint, _alembic_quote=True):
if isinstance(constraint.name, elements._defer_name):
name = naming._constraint_name_for_table(
constraint, constraint.table
@@ -3725,7 +3725,10 @@ class IdentifierPreparer(object):
else:
self.dialect.validate_identifier(name)
- return self.quote(name)
+ if not _alembic_quote:
+ return name
+ else:
+ return self.quote(name)
def format_index(self, index):
return self.format_constraint(index)