mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
DBManager: better handle for not supported constraint types (fix #7544)
This commit is contained in:
parent
5e282206c9
commit
f5aef0f549
@ -976,8 +976,8 @@ class TableField(TableSubItemObject):
|
||||
class TableConstraint(TableSubItemObject):
|
||||
""" class that represents a constraint of a table (relation) """
|
||||
|
||||
TypeCheck, TypeForeignKey, TypePrimaryKey, TypeUnique = range(4)
|
||||
types = { "c" : TypeCheck, "f" : TypeForeignKey, "p" : TypePrimaryKey, "u" : TypeUnique }
|
||||
TypeCheck, TypeForeignKey, TypePrimaryKey, TypeUnique, TypeExclusion, TypeUnknown = range(6)
|
||||
types = { "c" : TypeCheck, "f" : TypeForeignKey, "p" : TypePrimaryKey, "u" : TypeUnique, "x" : TypeExclusion }
|
||||
|
||||
onAction = { "a" : "NO ACTION", "r" : "RESTRICT", "c" : "CASCADE", "n" : "SET NULL", "d" : "SET DEFAULT" }
|
||||
matchTypes = { "u" : "UNSPECIFIED", "f" : "FULL", "p" : "PARTIAL" }
|
||||
@ -991,6 +991,7 @@ class TableConstraint(TableSubItemObject):
|
||||
if self.type == TableConstraint.TypePrimaryKey: return "Primary key"
|
||||
if self.type == TableConstraint.TypeForeignKey: return "Foreign key"
|
||||
if self.type == TableConstraint.TypeUnique: return "Unique"
|
||||
if self.type == TableConstraint.TypeExclusion: return "Exclusion"
|
||||
return 'Unknown'
|
||||
|
||||
def fields(self):
|
||||
|
@ -321,9 +321,13 @@ class PGTableField(TableField):
|
||||
class PGTableConstraint(TableConstraint):
|
||||
def __init__(self, row, table):
|
||||
TableConstraint.__init__(self, table)
|
||||
self.name, constr_type, self.isDefferable, self.isDeffered, columns = row[:5]
|
||||
self.name, constr_type_str, self.isDefferable, self.isDeffered, columns = row[:5]
|
||||
self.columns = map(int, columns.split(' '))
|
||||
self.type = TableConstraint.types[constr_type] # convert to enum
|
||||
|
||||
if constr_type_str in TableConstraint.types:
|
||||
self.type = TableConstraint.types[constr_type_str]
|
||||
else:
|
||||
self.type = TableConstraint.TypeUnknown
|
||||
|
||||
if self.type == TableConstraint.TypeCheck:
|
||||
self.checkSource = row[5]
|
||||
|
Loading…
x
Reference in New Issue
Block a user