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-Tag: rel_0_8_3~88 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=436ba1601d33de048a17e39a14856409c4e9c3b7;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 c650e769f5..99702a2f0c 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/doc/build/changelog/changelog_08.rst b/doc/build/changelog/changelog_08.rst index ded97c8d84..f266b2e6ef 100644 --- a/doc/build/changelog/changelog_08.rst +++ b/doc/build/changelog/changelog_08.rst @@ -6,6 +6,13 @@ .. changelog:: :version: 0.8.3 + .. 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. Also in 0.7.11. + .. change:: :tags: bug, orm :tickets: 2778 diff --git a/lib/sqlalchemy/sql/util.py b/lib/sqlalchemy/sql/util.py index 4aa2d74968..61730f1f02 100644 --- a/lib/sqlalchemy/sql/util.py +++ b/lib/sqlalchemy/sql/util.py @@ -276,7 +276,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 8b14d23a98..c2efd8f9d7 100644 --- a/test/sql/test_quote.py +++ b/test/sql/test_quote.py @@ -542,6 +542,28 @@ class QuoteTest(fixtures.TestBase, AssertsCompiledSQL): 'Foo.T1' ) + def test_quote_flag_propagate_check_constraint(self): + m = MetaData() + t = Table('t', m, Column('x', Integer, quote=True)) + CheckConstraint(t.c.x > 5) + 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.""" @@ -596,3 +618,4 @@ class PreparerTest(fixtures.TestBase): a_eq(unformat('foo.`bar`'), ['foo', 'bar']) a_eq(unformat('`foo`.bar'), ['foo', 'bar']) a_eq(unformat('`foo`.`b``a``r`.`baz`'), ['foo', 'b`a`r', 'baz']) +