summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql/test_compiler.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-11-30 13:53:26 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2013-11-30 13:53:26 -0500
commit66773a8801a584d36b514e22a03d92d66fb2931b (patch)
treee891ac17418ddded7524e8a85f19b9c2a34a6d7b /test/dialect/postgresql/test_compiler.py
parent53e93d50caee40fa0873a16ec50a0e09996c8151 (diff)
downloadsqlalchemy-66773a8801a584d36b514e22a03d92d66fb2931b.tar.gz
- Fixed bug where values within an ENUM weren't escaped for single
quote signs. Note that this is backwards-incompatible for existing workarounds that manually escape the single quotes. [ticket:2878]
Diffstat (limited to 'test/dialect/postgresql/test_compiler.py')
-rw-r--r--test/dialect/postgresql/test_compiler.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py
index 409d6f03a..dd7df2be3 100644
--- a/test/dialect/postgresql/test_compiler.py
+++ b/test/dialect/postgresql/test_compiler.py
@@ -16,6 +16,7 @@ from sqlalchemy.dialects.postgresql import base as postgresql
from sqlalchemy.dialects.postgresql import TSRANGE
from sqlalchemy.orm import mapper, aliased, Session
from sqlalchemy.sql import table, column, operators
+from sqlalchemy.util import u
class SequenceTest(fixtures.TestBase, AssertsCompiledSQL):
@@ -106,6 +107,21 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
'AS length_1', dialect=dialect)
+ def test_create_enum(self):
+ # test escaping and unicode within CREATE TYPE for ENUM
+ typ = postgresql.ENUM(
+ "val1", "val2", "val's 3", u('méil'), name="myname")
+ self.assert_compile(postgresql.CreateEnumType(typ),
+ u("CREATE TYPE myname AS ENUM ('val1', 'val2', 'val''s 3', 'méil')")
+ )
+
+ typ = postgresql.ENUM(
+ "val1", "val2", "val's 3", name="PleaseQuoteMe")
+ self.assert_compile(postgresql.CreateEnumType(typ),
+ "CREATE TYPE \"PleaseQuoteMe\" AS ENUM "
+ "('val1', 'val2', 'val''s 3')"
+ )
+
def test_create_partial_index(self):
m = MetaData()
tbl = Table('testtbl', m, Column('data', Integer))