mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-24 00:05:18 -05:00
[processing] Ignore geom for non geom tables for ImportIntoPostGIS
This fixes an error where trying to import non geometry tables using the "Import Into PostGIS" algorithm results in a database error.
This commit is contained in:
parent
4e3bbef9a4
commit
3be82ff708
6
python/plugins/processing/algs/qgis/ImportIntoPostGIS.py
Normal file → Executable file
6
python/plugins/processing/algs/qgis/ImportIntoPostGIS.py
Normal file → Executable file
@ -103,6 +103,10 @@ class ImportIntoPostGIS(GeoAlgorithm):
|
||||
if dropStringLength:
|
||||
options['dropStringConstraints'] = True
|
||||
|
||||
#clear geometry column for non-geometry tables
|
||||
if not layer.hasGeometryType():
|
||||
geomColumn = None
|
||||
|
||||
uri = QgsDataSourceURI()
|
||||
uri.setConnection(host, str(port), database, username, password)
|
||||
if primaryKeyField:
|
||||
@ -123,7 +127,7 @@ class ImportIntoPostGIS(GeoAlgorithm):
|
||||
raise GeoAlgorithmExecutionException(
|
||||
'Error importing to PostGIS\n%s' % errMsg)
|
||||
|
||||
if createIndex:
|
||||
if geomColumn and createIndex:
|
||||
db.create_spatial_index(table, schema, geomColumn)
|
||||
|
||||
db.vacuum_analyze(table, schema)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user