Merge pull request #30320 from olivierdalang/fix_30260

fix #30260
This commit is contained in:
Matthias Kuhn 2019-06-22 09:44:41 +02:00 committed by GitHub
commit 3a30a5b6ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -713,13 +713,6 @@ class Table(DbItemObject):
geomCol = self.geomColumn if self.type in [Table.VectorType, Table.RasterType] else ""
uniqueCol = self.getValidQgisUniqueFields(True) if self.isView else None
uri.setDataSource(schema, self.name, geomCol if geomCol else None, None, uniqueCol.name if uniqueCol else "")
uri.setSrid(str(self.srid))
for f in self.fields():
if f.primaryKey:
uri.setKeyColumn(f.name)
break
uri.setWkbType(QgsWkbTypes.parseType(self.geomType))
return uri
def mimeUri(self):
@ -990,6 +983,16 @@ class VectorTable(Table):
return VectorTableInfo(self)
def uri(self):
uri = super().uri()
uri.setSrid(str(self.srid))
for f in self.fields():
if f.primaryKey:
uri.setKeyColumn(f.name)
break
uri.setWkbType(QgsWkbTypes.parseType(self.geomType))
return uri
def hasSpatialIndex(self, geom_column=None):
geom_column = geom_column if geom_column is not None else self.geomColumn
fld = None