mirror of
https://github.com/qgis/QGIS.git
synced 2025-11-22 00:14:55 -05: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 TableConstraint(TableSubItemObject):
|
||||||
""" class that represents a constraint of a table (relation) """
|
""" class that represents a constraint of a table (relation) """
|
||||||
|
|
||||||
TypeCheck, TypeForeignKey, TypePrimaryKey, TypeUnique = range(4)
|
TypeCheck, TypeForeignKey, TypePrimaryKey, TypeUnique, TypeExclusion, TypeUnknown = range(6)
|
||||||
types = { "c" : TypeCheck, "f" : TypeForeignKey, "p" : TypePrimaryKey, "u" : TypeUnique }
|
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" }
|
onAction = { "a" : "NO ACTION", "r" : "RESTRICT", "c" : "CASCADE", "n" : "SET NULL", "d" : "SET DEFAULT" }
|
||||||
matchTypes = { "u" : "UNSPECIFIED", "f" : "FULL", "p" : "PARTIAL" }
|
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.TypePrimaryKey: return "Primary key"
|
||||||
if self.type == TableConstraint.TypeForeignKey: return "Foreign key"
|
if self.type == TableConstraint.TypeForeignKey: return "Foreign key"
|
||||||
if self.type == TableConstraint.TypeUnique: return "Unique"
|
if self.type == TableConstraint.TypeUnique: return "Unique"
|
||||||
|
if self.type == TableConstraint.TypeExclusion: return "Exclusion"
|
||||||
return 'Unknown'
|
return 'Unknown'
|
||||||
|
|
||||||
def fields(self):
|
def fields(self):
|
||||||
|
|||||||
@ -321,9 +321,13 @@ class PGTableField(TableField):
|
|||||||
class PGTableConstraint(TableConstraint):
|
class PGTableConstraint(TableConstraint):
|
||||||
def __init__(self, row, table):
|
def __init__(self, row, table):
|
||||||
TableConstraint.__init__(self, 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.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:
|
if self.type == TableConstraint.TypeCheck:
|
||||||
self.checkSource = row[5]
|
self.checkSource = row[5]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user