summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-07-17 11:18:59 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2013-07-17 11:18:59 -0400
commit0a54a4a4b0897bb8eaaf7a7857fb54924ccbd7ef (patch)
tree720aad2b844dbf821d339d365aa77777c7168f3e
parentc59199c9879c3535dc48647a3f61281f0ac631f4 (diff)
downloadsqlalchemy-0a54a4a4b0897bb8eaaf7a7857fb54924ccbd7ef.tar.gz
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]
-rw-r--r--doc/build/changelog/changelog_07.rst7
-rw-r--r--doc/build/changelog/changelog_08.rst7
-rw-r--r--doc/build/changelog/changelog_09.rst7
-rw-r--r--lib/sqlalchemy/sql/util.py4
-rw-r--r--test/sql/test_quote.py23
5 files changed, 47 insertions, 1 deletions
diff --git a/doc/build/changelog/changelog_07.rst b/doc/build/changelog/changelog_07.rst
index c650e769f..99702a2f0 100644
--- a/doc/build/changelog/changelog_07.rst
+++ b/doc/build/changelog/changelog_07.rst
@@ -7,6 +7,13 @@
: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 d6af87132..4e5454180 100644
--- a/doc/build/changelog/changelog_08.rst
+++ b/doc/build/changelog/changelog_08.rst
@@ -7,6 +7,13 @@
: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/doc/build/changelog/changelog_09.rst b/doc/build/changelog/changelog_09.rst
index 78c7e0c9a..02a5c1d81 100644
--- a/doc/build/changelog/changelog_09.rst
+++ b/doc/build/changelog/changelog_09.rst
@@ -7,6 +7,13 @@
:version: 0.9.0
.. 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.8.3, 0.7.11.
+
+ .. change::
:tags: bug, orm
:tickets: 2778
diff --git a/lib/sqlalchemy/sql/util.py b/lib/sqlalchemy/sql/util.py
index c894357b5..6796d7edb 100644
--- a/lib/sqlalchemy/sql/util.py
+++ b/lib/sqlalchemy/sql/util.py
@@ -291,7 +291,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 717f0f797..c92f1ac80 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'])
+