Skip to content

Commit 906a51e

Browse files
authored
Skipped NOT NULL constraints on PostgreSQL 18+.
Thanks Simon Charette for the implementation idea.
1 parent 8b84364 commit 906a51e

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

django/db/backends/postgresql/introspection.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,9 @@ def get_constraints(self, cursor, table_name):
206206
cl.reloptions
207207
FROM pg_constraint AS c
208208
JOIN pg_class AS cl ON c.conrelid = cl.oid
209-
WHERE cl.relname = %s AND pg_catalog.pg_table_is_visible(cl.oid)
209+
WHERE cl.relname = %s
210+
AND pg_catalog.pg_table_is_visible(cl.oid)
211+
AND c.contype != 'n'
210212
""",
211213
[table_name],
212214
)

0 commit comments

Comments
 (0)