--- /dev/null
+.. change::
+ :tags: bug, postgresql
+ :tickets: 4701
+
+ 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.
"name": enum["name"],
"schema": enum["schema"],
"visible": enum["visible"],
- "labels": [enum["label"]],
+ "labels": [],
}
+ if enum["label"] is not None:
+ enum_rec["labels"].append(enum["label"])
enums.append(enum_rec)
return enums
],
)
+ @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):