From 7b86a06d2d7e3e4d7e6b822f19d5085dfd948e09 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 26 Apr 2010 00:11:22 -0400 Subject: [PATCH] - Fixed errant space character when generating ADD CONSTRAINT for a named UNIQUE constraint. --- CHANGES | 3 +++ lib/sqlalchemy/sql/compiler.py | 2 +- test/sql/test_constraints.py | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 01283843f4..d7e7b3dfc3 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 7a1821a70d..0e5f3499ec 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 97f5190d4c..eed77ed839 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 -- 2.47.2