Skip to content

Commit 75461aa

Browse files
committedMay 28, 2016
[Processing] Fix ogr2ogr postgis table overwrite
1 parent 94d88e6 commit 75461aa

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed
 

‎python/plugins/processing/algs/gdal/ogr2ogrtabletopostgislist.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,12 @@ def getConsoleCommands(self):
170170
arguments.append(pkstring)
171171
elif primary_key is not None:
172172
arguments.append("-lco FID=" + primary_key)
173-
if len(table) > 0:
174-
arguments.append('-nln')
175-
arguments.append(table)
173+
if len(table) == 0:
174+
table = ogrLayerName(inLayer).lower()
175+
if schema:
176+
table = '{}.{}'.format(schema, table)
177+
arguments.append('-nln')
178+
arguments.append(table)
176179
if skipfailures:
177180
arguments.append('-skipfailures')
178181
if where:

‎python/plugins/processing/algs/gdal/ogr2ogrtopostgis.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,12 @@ def getConsoleCommands(self):
227227
arguments.append(pkstring)
228228
elif primary_key is not None:
229229
arguments.append("-lco FID=" + primary_key)
230-
if len(table) > 0:
231-
arguments.append('-nln')
232-
arguments.append(table)
230+
if len(table) == 0:
231+
table = ogrLayerName(inLayer).lower()
232+
if schema:
233+
table = '{}.{}'.format(schema, table)
234+
arguments.append('-nln')
235+
arguments.append(table)
233236
if len(ssrs) > 0:
234237
arguments.append('-s_srs')
235238
arguments.append(ssrs)

‎python/plugins/processing/algs/gdal/ogr2ogrtopostgislist.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,12 @@ def getConsoleCommands(self):
233233
arguments.append(pkstring)
234234
elif primary_key is not None:
235235
arguments.append("-lco FID=" + primary_key)
236-
if len(table) > 0:
237-
arguments.append('-nln')
238-
arguments.append(table)
236+
if len(table) == 0:
237+
table = ogrLayerName(inLayer).lower()
238+
if schema:
239+
table = '{}.{}'.format(schema, table)
240+
arguments.append('-nln')
241+
arguments.append(table)
239242
if len(ssrs) > 0:
240243
arguments.append('-s_srs')
241244
arguments.append(ssrs)

0 commit comments

Comments
 (0)
Please sign in to comment.