Skip to content

Commit 3be82ff

Browse files
committed
[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.
1 parent 4e3bbef commit 3be82ff

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

python/plugins/processing/algs/qgis/ImportIntoPostGIS.py

100644100755
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ def processAlgorithm(self, progress):
103103
if dropStringLength:
104104
options['dropStringConstraints'] = True
105105

106+
#clear geometry column for non-geometry tables
107+
if not layer.hasGeometryType():
108+
geomColumn = None
109+
106110
uri = QgsDataSourceURI()
107111
uri.setConnection(host, str(port), database, username, password)
108112
if primaryKeyField:
@@ -123,7 +127,7 @@ def processAlgorithm(self, progress):
123127
raise GeoAlgorithmExecutionException(
124128
'Error importing to PostGIS\n%s' % errMsg)
125129

126-
if createIndex:
130+
if geomColumn and createIndex:
127131
db.create_spatial_index(table, schema, geomColumn)
128132

129133
db.vacuum_analyze(table, schema)

0 commit comments

Comments
 (0)