Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing] Add option to Import into PostGIS algorithm to drop leng…
…th constraints on character fields
  • Loading branch information
nyalldawson committed May 20, 2014
1 parent 3470b1d commit 2eda533
Showing 1 changed file with 6 additions and 0 deletions.
Expand Up @@ -50,6 +50,7 @@ class ImportIntoPostGIS(GeoAlgorithm):
CREATEINDEX = 'CREATEINDEX'
GEOMETRY_COLUMN = 'GEOMETRY_COLUMN'
LOWERCASE_NAMES = 'LOWERCASE_NAMES'
DROP_STRING_LENGTH = 'DROP_STRING_LENGTH'

def getIcon(self):
return QIcon(os.path.dirname(__file__) + '/../../images/postgis.png')
Expand All @@ -60,6 +61,7 @@ def processAlgorithm(self, progress):
overwrite = self.getParameterValue(self.OVERWRITE)
createIndex = self.getParameterValue(self.CREATEINDEX)
convertLowerCase = self.getParameterValue(self.LOWERCASE_NAMES)
dropStringLength = self.getParameterValue(self.DROP_STRING_LENGTH)
settings = QSettings()
mySettings = '/PostgreSQL/connections/' + connection
try:
Expand Down Expand Up @@ -96,6 +98,8 @@ def processAlgorithm(self, progress):
options['overwrite'] = True
if convertLowerCase:
options['lowercaseFieldNames'] = True
if dropStringLength:
options['dropStringConstraints'] = True
layerUri = self.getParameterValue(self.INPUT)
layer = dataobjects.getObjectFromUri(layerUri)
(ret, errMsg) = QgsVectorLayerImport.importLayer(
Expand Down Expand Up @@ -140,3 +144,5 @@ def defineCharacteristics(self):
'Create spatial index', True))
self.addParameter(ParameterBoolean(self.LOWERCASE_NAMES,
'Convert field names to lowercase', False))
self.addParameter(ParameterBoolean(self.DROP_STRING_LENGTH,
'Drop length constraints on character fields', False))

0 comments on commit 2eda533

Please sign in to comment.