summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES3
-rw-r--r--lib/sqlalchemy/sql/compiler.py2
-rw-r--r--test/sql/test_constraints.py4
3 files changed, 6 insertions, 3 deletions
diff --git a/CHANGES b/CHANGES
index 01283843f..d7e7b3dfc 100644
--- a/CHANGES
+++ b/CHANGES
@@ -9,6 +9,9 @@ CHANGES
- Fixed bug that prevented implicit RETURNING from functioning
properly with composite primary key that contained zeroes.
[ticket:1778]
+
+ - Fixed errant space character when generating ADD CONSTRAINT
+ for a named UNIQUE constraint.
- oracle
- Added a check for cx_oracle versions lower than version 5,
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py
index 7a1821a70..0e5f3499e 100644
--- a/lib/sqlalchemy/sql/compiler.py
+++ b/lib/sqlalchemy/sql/compiler.py
@@ -1299,7 +1299,7 @@ class DDLCompiler(engine.Compiled):
def visit_unique_constraint(self, constraint):
text = ""
if constraint.name is not None:
- text += "CONSTRAINT %s " % self.preparer.format_constraint(constraint)
+ text += "CONSTRAINT %s" % self.preparer.format_constraint(constraint)
text += " UNIQUE (%s)" % (', '.join(self.preparer.quote(c.name, c.quote) for c in constraint))
text += self.define_constraint_deferrability(constraint)
return text
diff --git a/test/sql/test_constraints.py b/test/sql/test_constraints.py
index 97f5190d4..eed77ed83 100644
--- a/test/sql/test_constraints.py
+++ b/test/sql/test_constraints.py
@@ -376,13 +376,13 @@ class ConstraintCompilationTest(TestBase, AssertsCompiledSQL):
t2.append_constraint(constraint)
self.assert_compile(
schema.AddConstraint(constraint),
- "ALTER TABLE t2 ADD CONSTRAINT uq_cst UNIQUE (a, b)"
+ "ALTER TABLE t2 ADD CONSTRAINT uq_cst UNIQUE (a, b)"
)
constraint = UniqueConstraint(t2.c.a, t2.c.b, name="uq_cs2")
self.assert_compile(
schema.AddConstraint(constraint),
- "ALTER TABLE t2 ADD CONSTRAINT uq_cs2 UNIQUE (a, b)"
+ "ALTER TABLE t2 ADD CONSTRAINT uq_cs2 UNIQUE (a, b)"
)
assert t.c.a.primary_key is False