summaryrefslogtreecommitdiff
path: root/test/dialect/test_postgresql.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-06-25 13:11:06 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2010-06-25 13:11:06 -0400
commit3eab7982537426d4dc1c467df1371dea3b0a0a4e (patch)
tree87e5c85749a8bc36ae900046bdf6f45c99c47901 /test/dialect/test_postgresql.py
parent7dcfc49b349377b86f4d7d0e0c804f4d19282d15 (diff)
downloadsqlalchemy-3eab7982537426d4dc1c467df1371dea3b0a0a4e.tar.gz
- Won't generate "CREATE TYPE" / "DROP TYPE" if
using types.Enum on a PG version prior to 8.3 - the supports_native_enum flag is fully honored. [ticket:1836]
Diffstat (limited to 'test/dialect/test_postgresql.py')
-rw-r--r--test/dialect/test_postgresql.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/dialect/test_postgresql.py b/test/dialect/test_postgresql.py
index 14814bc20..d947ad4c4 100644
--- a/test/dialect/test_postgresql.py
+++ b/test/dialect/test_postgresql.py
@@ -349,6 +349,50 @@ class EnumTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL):
finally:
metadata.drop_all()
+
+ def test_non_native_type(self):
+ metadata = MetaData()
+ t1 = Table('foo', metadata,
+ Column('bar', Enum('one', 'two', 'three', name='myenum', native_enum=False))
+ )
+
+ def go():
+ t1.create(testing.db)
+
+ try:
+ self.assert_sql(testing.db, go, [], with_sequences=[
+ (
+ "CREATE TABLE foo (\tbar VARCHAR(5), \t"
+ "CONSTRAINT myenum CHECK (bar IN ('one', 'two', 'three')))",
+ {}
+ )]
+ )
+ finally:
+ metadata.drop_all(testing.db)
+
+ def test_non_native_dialect(self):
+ engine = engines.testing_engine()
+ engine.connect()
+ engine.dialect.supports_native_enum = False
+
+ metadata = MetaData()
+ t1 = Table('foo', metadata,
+ Column('bar', Enum('one', 'two', 'three', name='myenum'))
+ )
+
+ def go():
+ t1.create(engine)
+
+ try:
+ self.assert_sql(engine, go, [], with_sequences=[
+ (
+ "CREATE TABLE foo (\tbar VARCHAR(5), \t"
+ "CONSTRAINT myenum CHECK (bar IN ('one', 'two', 'three')))",
+ {}
+ )]
+ )
+ finally:
+ metadata.drop_all(engine)
def test_standalone_enum(self):
metadata = MetaData(testing.db)