mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-01 00:46:20 -05:00
Merge pull request #35983 from espinafre/dbmanager_pgsql_constraint_trigger
Handle CONSTRAINT TRIGGER on DB Manager/PostgreSQL.
This commit is contained in:
commit
d62c982b6f
@ -652,12 +652,15 @@ class PostGisDBConnector(DBConnector):
|
||||
version_number = int(self.getInfo()[0].split(' ')[1].split('.')[0])
|
||||
con_col_name = 'consrc' if version_number < 12 else 'conbin'
|
||||
|
||||
# In the query below, we exclude rows where pg_constraint.contype whose values are equal to 't'
|
||||
# because 't' describes a CONSTRAINT TRIGGER, which is not really a constraint in the traditional
|
||||
# sense, but a special type of trigger, and an extension to the SQL standard.
|
||||
sql = u"""SELECT c.conname, c.contype, c.condeferrable, c.condeferred, array_to_string(c.conkey, ' '), c.%s,
|
||||
t2.relname, c.confupdtype, c.confdeltype, c.confmatchtype, array_to_string(c.confkey, ' ') FROM pg_constraint c
|
||||
LEFT JOIN pg_class t ON c.conrelid = t.oid
|
||||
LEFT JOIN pg_class t2 ON c.confrelid = t2.oid
|
||||
JOIN pg_namespace nsp ON t.relnamespace = nsp.oid
|
||||
WHERE t.relname = %s %s """ % (con_col_name, self.quoteString(tablename), schema_where)
|
||||
WHERE c.contype <> 't' AND t.relname = %s %s """ % (con_col_name, self.quoteString(tablename), schema_where)
|
||||
|
||||
c = self._execute(None, sql)
|
||||
res = self._fetchall(c)
|
||||
|
Loading…
x
Reference in New Issue
Block a user