]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Fixed bug in :class:`.CheckConstraint` DDL where the "quote" flag from a
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 17 Jul 2013 15:18:59 +0000 (11:18 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 17 Jul 2013 15:22:42 +0000 (11:22 -0400)
:class:`.Column` object would not be propagated.  Also in 0.8.3, 0.7.11.
[ticket:2784]

doc/build/changelog/changelog_07.rst
lib/sqlalchemy/sql/util.py
test/sql/test_quote.py

index 476a4f3594c94cbe4ffbc22654e3f2a900022575..b3b37861e4264ab4bbb5a502f15dcab4e215b6c0 100644 (file)
@@ -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
index bf4235ad7f04d3daeaeb6033ea7ee986b678f34e..9d55a99dc866b03cf6fb2a4fe79ad999a2e33483 100644 (file)
@@ -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
 
index a714002b1a9d7eabbead5c66f9031be2fc72f780..c6e331e660620db6a65c9b019847a895ce8c8bce 100644 (file)
@@ -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."""