mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-16 00:03:12 -04:00
dbmanager: avoid duplicate field error (fix #6279)
This commit is contained in:
parent
3542b0897d
commit
0239795d79
@ -58,11 +58,14 @@ class DlgImportVector(QDialog, Ui_DlgImportVector):
|
|||||||
self.populateEncodings()
|
self.populateEncodings()
|
||||||
self.updateUi()
|
self.updateUi()
|
||||||
|
|
||||||
|
# set default values
|
||||||
self.cboTable.setEditText(self.outUri.table())
|
self.cboTable.setEditText(self.outUri.table())
|
||||||
|
|
||||||
pk = self.outUri.keyColumn()
|
pk = self.outUri.keyColumn()
|
||||||
self.editPrimaryKey.setText(pk if pk != "" else self.default_pk)
|
self.editPrimaryKey.setText(pk if pk != "" else self.default_pk)
|
||||||
geom = self.outUri.geometryColumn()
|
geom = self.outUri.geometryColumn()
|
||||||
self.editGeomColumn.setText(geom if geom != "" else self.default_geom)
|
self.editGeomColumn.setText(geom if geom != "" else self.default_geom)
|
||||||
|
|
||||||
inCrs = self.inLayer.crs()
|
inCrs = self.inLayer.crs()
|
||||||
srid = inCrs.postgisSrid() if inCrs.isValid() else 4236
|
srid = inCrs.postgisSrid() if inCrs.isValid() else 4236
|
||||||
self.editSourceSrid.setText( "%s" % srid )
|
self.editSourceSrid.setText( "%s" % srid )
|
||||||
@ -73,7 +76,7 @@ class DlgImportVector(QDialog, Ui_DlgImportVector):
|
|||||||
|
|
||||||
def checkSupports(self):
|
def checkSupports(self):
|
||||||
allowSpatial = self.db.connector.hasSpatialSupport()
|
allowSpatial = self.db.connector.hasSpatialSupport()
|
||||||
self.chkGeomColumn.setEnabled(allowSpatial)
|
self.chkGeomColumn.setEnabled(allowSpatial and self.inLayer.hasGeometryType())
|
||||||
self.chkSourceSrid.setEnabled(allowSpatial)
|
self.chkSourceSrid.setEnabled(allowSpatial)
|
||||||
self.chkTargetSrid.setEnabled(allowSpatial)
|
self.chkTargetSrid.setEnabled(allowSpatial)
|
||||||
self.chkSpatialIndex.setEnabled(allowSpatial)
|
self.chkSpatialIndex.setEnabled(allowSpatial)
|
||||||
@ -168,11 +171,10 @@ class DlgImportVector(QDialog, Ui_DlgImportVector):
|
|||||||
schema = self.outUri.schema() if not self.cboSchema.isEnabled() else self.cboSchema.currentText()
|
schema = self.outUri.schema() if not self.cboSchema.isEnabled() else self.cboSchema.currentText()
|
||||||
table = self.cboTable.currentText()
|
table = self.cboTable.currentText()
|
||||||
|
|
||||||
|
# get pk and geom field names from the source layer or use the
|
||||||
|
# ones defined by the user
|
||||||
pk = self.outUri.keyColumn() if not self.chkPrimaryKey.isChecked() else self.editPrimaryKey.text()
|
pk = self.outUri.keyColumn() if not self.chkPrimaryKey.isChecked() else self.editPrimaryKey.text()
|
||||||
pk = pk if pk != "" else self.default_pk
|
|
||||||
|
|
||||||
geom = self.outUri.geometryColumn() if not self.chkGeomColumn.isChecked() else self.editGeomColumn.text()
|
geom = self.outUri.geometryColumn() if not self.chkGeomColumn.isChecked() else self.editGeomColumn.text()
|
||||||
if self.inLayer.hasGeometryType():
|
|
||||||
geom = geom if geom != "" else self.default_geom
|
geom = geom if geom != "" else self.default_geom
|
||||||
|
|
||||||
self.outUri.setDataSource( schema, table, geom, QString(), pk )
|
self.outUri.setDataSource( schema, table, geom, QString(), pk )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user