--- /dev/null
+.. change::
+ :tags: bug, postgresql
+ :tickets: 11751
+
+ Add SQL typing to reflection query used to retrieve a the structure
+ of IDENTITY columns, adding explicit JSON typing to the query to suit
+ unusual PostgreSQL driver configurations that don't support JSON natively.
+
+.. change::
+ :tags: bug, postgresql
+
+ Fixed issue affecting PostgreSQL 17.3 and greater where reflection of
+ domains with "NOT NULL" as part of their definition would include an
+ invalid constraint entry in the data returned by
+ :meth:`_postgresql.PGInspector.get_domains` corresponding to an additional
+ "NOT NULL" constraint that isn't a CHECK constraint; the existing
+ ``"nullable"`` entry in the dictionary already indicates if the domain
+ includes a "not null" constraint. Note that such domains also cannot be
+ reflected on PostgreSQL 17.0 through 17.2 due to a bug on the PostgreSQL
+ side; if encountering errors in reflection of domains which include NOT
+ NULL, upgrade to PostgreSQL server 17.3 or greater.
pg_catalog.pg_sequence.c.seqcache,
"cycle",
pg_catalog.pg_sequence.c.seqcycle,
+ type_=sqltypes.JSON(),
)
)
.select_from(pg_catalog.pg_sequence)
key=lambda t: t[0],
)
for name, def_ in sorted_constraints:
- # constraint is in the form "CHECK (expression)".
+ # constraint is in the form "CHECK (expression)"
+ # or "NOT NULL". Ignore the "NOT NULL" and
# remove "CHECK (" and the tailing ")".
- check = def_[7:-1]
- constraints.append({"name": name, "check": check})
-
+ if def_.casefold().startswith("check"):
+ check = def_[7:-1]
+ constraints.append({"name": name, "check": check})
domain_rec: ReflectedDomain = {
"name": domain["name"],
"schema": domain["schema"],
@testing.fixture
def testtable(self, connection, testdomain):
connection.exec_driver_sql(
- "CREATE TABLE testtable (question integer, answer " "testdomain)"
+ "CREATE TABLE testtable (question integer, answer testdomain)"
)
yield
connection.exec_driver_sql("DROP TABLE testtable")