Skip to content

Commit 2eda533

Browse files
committed
[processing] Add option to Import into PostGIS algorithm to drop length constraints on character fields
1 parent 3470b1d commit 2eda533

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

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

+6
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class ImportIntoPostGIS(GeoAlgorithm):
5050
CREATEINDEX = 'CREATEINDEX'
5151
GEOMETRY_COLUMN = 'GEOMETRY_COLUMN'
5252
LOWERCASE_NAMES = 'LOWERCASE_NAMES'
53+
DROP_STRING_LENGTH = 'DROP_STRING_LENGTH'
5354

5455
def getIcon(self):
5556
return QIcon(os.path.dirname(__file__) + '/../../images/postgis.png')
@@ -60,6 +61,7 @@ def processAlgorithm(self, progress):
6061
overwrite = self.getParameterValue(self.OVERWRITE)
6162
createIndex = self.getParameterValue(self.CREATEINDEX)
6263
convertLowerCase = self.getParameterValue(self.LOWERCASE_NAMES)
64+
dropStringLength = self.getParameterValue(self.DROP_STRING_LENGTH)
6365
settings = QSettings()
6466
mySettings = '/PostgreSQL/connections/' + connection
6567
try:
@@ -96,6 +98,8 @@ def processAlgorithm(self, progress):
9698
options['overwrite'] = True
9799
if convertLowerCase:
98100
options['lowercaseFieldNames'] = True
101+
if dropStringLength:
102+
options['dropStringConstraints'] = True
99103
layerUri = self.getParameterValue(self.INPUT)
100104
layer = dataobjects.getObjectFromUri(layerUri)
101105
(ret, errMsg) = QgsVectorLayerImport.importLayer(
@@ -140,3 +144,5 @@ def defineCharacteristics(self):
140144
'Create spatial index', True))
141145
self.addParameter(ParameterBoolean(self.LOWERCASE_NAMES,
142146
'Convert field names to lowercase', False))
147+
self.addParameter(ParameterBoolean(self.DROP_STRING_LENGTH,
148+
'Drop length constraints on character fields', False))

0 commit comments

Comments
 (0)