Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing] fixes for 'import into PostGIS' alg
fixes #15097
  • Loading branch information
volaya committed Oct 17, 2016
1 parent 61a10df commit e58177c
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions python/plugins/processing/algs/qgis/ImportIntoPostGIS.py
Expand Up @@ -94,7 +94,7 @@ def processAlgorithm(self, progress):
convertLowerCase = self.getParameterValue(self.LOWERCASE_NAMES)
dropStringLength = self.getParameterValue(self.DROP_STRING_LENGTH)
forceSinglePart = self.getParameterValue(self.FORCE_SINGLEPART)
primaryKeyField = self.getParameterValue(self.PRIMARY_KEY)
primaryKeyField = self.getParameterValue(self.PRIMARY_KEY) or 'id'
encoding = self.getParameterValue(self.ENCODING)

layerUri = self.getParameterValue(self.INPUT)
Expand All @@ -103,6 +103,7 @@ def processAlgorithm(self, progress):
table = self.getParameterValue(self.TABLENAME).strip()
if table == '':
table = layer.name()
table = "_".join(table.split(".")[:-1])
table = table.replace(' ', '').lower()[0:62]
providerName = 'postgres'

Expand All @@ -126,10 +127,7 @@ def processAlgorithm(self, progress):
geomColumn = None

uri = db.uri
if primaryKeyField:
uri.setDataSource(schema, table, geomColumn, '', primaryKeyField)
else:
uri.setDataSource(schema, table, geomColumn, '')
uri.setDataSource(schema, table, geomColumn, '', primaryKeyField)

if encoding:
layer.setProviderEncoding(encoding)
Expand Down

0 comments on commit e58177c

Please sign in to comment.