summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql/test_reflection.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-05-30 20:42:35 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2019-05-30 20:42:35 -0400
commit754e7f52cf64b72988bdf8211c603809b32c16de (patch)
treee925e74538d9d387f20f8abb3a0771b6f5be59b6 /test/dialect/postgresql/test_reflection.py
parentdf99e1ef5f334ce7f4c8118c3e0bdf2949f54de3 (diff)
downloadsqlalchemy-754e7f52cf64b72988bdf8211c603809b32c16de.tar.gz
PostgreSQL enum with no elements returns NULL for the "label", skip this
Fixed bug where PostgreSQL dialect could not correctly reflect an ENUM datatype that has no members, returning a list with ``None`` for the ``get_enums()`` call and raising a TypeError when reflecting a column which has such a datatype. The inspection now returns an empty list. Fixes: #4701 Change-Id: I202bab19728862cbc64deae211d5ba6a103b8317
Diffstat (limited to 'test/dialect/postgresql/test_reflection.py')
-rw-r--r--test/dialect/postgresql/test_reflection.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/dialect/postgresql/test_reflection.py b/test/dialect/postgresql/test_reflection.py
index ae1dff6d0..f2e491167 100644
--- a/test/dialect/postgresql/test_reflection.py
+++ b/test/dialect/postgresql/test_reflection.py
@@ -1291,6 +1291,33 @@ class ReflectionTest(fixtures.TestBase):
)
@testing.provide_metadata
+ def test_inspect_enum_empty(self):
+ enum_type = postgresql.ENUM(name="empty", metadata=self.metadata)
+ enum_type.create(testing.db)
+ inspector = reflection.Inspector.from_engine(testing.db)
+
+ eq_(
+ inspector.get_enums(),
+ [
+ {
+ "visible": True,
+ "labels": [],
+ "name": "empty",
+ "schema": "public",
+ }
+ ],
+ )
+
+ @testing.provide_metadata
+ def test_inspect_enum_empty_from_table(self):
+ Table(
+ "t", self.metadata, Column("x", postgresql.ENUM(name="empty"))
+ ).create(testing.db)
+
+ t = Table("t", MetaData(testing.db), autoload_with=testing.db)
+ eq_(t.c.x.type.enums, [])
+
+ @testing.provide_metadata
@testing.only_on("postgresql >= 8.5")
def test_reflection_with_unique_constraint(self):
insp = inspect(testing.db)