From: Mike Bayer Date: Wed, 17 Jul 2013 15:18:59 +0000 (-0400) Subject: Fixed bug in :class:`.CheckConstraint` DDL where the "quote" flag from a X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6f265a4e6555a6040db1a6dc566825c0ac263fc7;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Fixed bug in :class:`.CheckConstraint` DDL where the "quote" flag from a :class:`.Column` object would not be propagated. Also in 0.8.3, 0.7.11. [ticket:2784] --- diff --git a/doc/build/changelog/changelog_07.rst b/doc/build/changelog/changelog_07.rst index 476a4f3594..b3b37861e4 100644 --- a/doc/build/changelog/changelog_07.rst +++ b/doc/build/changelog/changelog_07.rst @@ -6,6 +6,13 @@ .. changelog:: :version: 0.7.11 + .. change:: + :tags: bug, sql + :tickets: 2784 + + Fixed bug in :class:`.CheckConstraint` DDL where the "quote" flag from a + :class:`.Column` object would not be propagated. + .. change:: :tags: bug, orm :tickets: 2699 diff --git a/lib/sqlalchemy/sql/util.py b/lib/sqlalchemy/sql/util.py index bf4235ad7f..9d55a99dc8 100644 --- a/lib/sqlalchemy/sql/util.py +++ b/lib/sqlalchemy/sql/util.py @@ -203,7 +203,9 @@ def expression_as_ddl(clause): return expression.literal_column(_quote_ddl_expr(element.value)) elif isinstance(element, expression.ColumnClause) and \ element.table is not None: - return expression.column(element.name) + col = expression.column(element.name) + col.quote = element.quote + return col else: return None diff --git a/test/sql/test_quote.py b/test/sql/test_quote.py index a714002b1a..c6e331e660 100644 --- a/test/sql/test_quote.py +++ b/test/sql/test_quote.py @@ -182,6 +182,29 @@ class QuoteTest(fixtures.TestBase, AssertsCompiledSQL): self.assert_compile(x, '''SELECT "ImATable".col1, "ImATable"."from", "ImATable".louisville, "ImATable"."order" FROM "ImATable"''') + def test_quote_flag_propagate_check_constraint(self): + m = MetaData() + t = Table('t', m, Column('x', Integer, quote=True)) + const = CheckConstraint(t.c.x > 5) + t.append_constraint(const) + self.assert_compile( + schema.CreateTable(t), + "CREATE TABLE t (" + '"x" INTEGER, ' + 'CHECK ("x" > 5)' + ")" + ) + + def test_quote_flag_propagate_index(self): + m = MetaData() + t = Table('t', m, Column('x', Integer, quote=True)) + idx = Index("foo", t.c.x) + self.assert_compile( + schema.CreateIndex(idx), + 'CREATE INDEX foo ON t ("x")' + ) + + class PreparerTest(fixtures.TestBase): """Test the db-agnostic quoting services of IdentifierPreparer."""