Skip to content

Commit

Permalink
[processing] Ignore geom for non geom tables for ImportIntoPostGIS
Browse files Browse the repository at this point in the history
This fixes an error where trying to import non geometry tables
using the "Import Into PostGIS" algorithm results in a database
error.
  • Loading branch information
nyalldawson committed Oct 27, 2014
1 parent 4e3bbef commit 3be82ff
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion python/plugins/processing/algs/qgis/ImportIntoPostGIS.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ def processAlgorithm(self, progress):
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:
Expand All @@ -123,7 +127,7 @@ def processAlgorithm(self, progress):
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)
Expand Down

0 comments on commit 3be82ff

Please sign in to comment.