Bug report #19210

'overwrite' flag in qgspostgresprovider createEmptyLayer ignored

Added by Robert Collins almost 6 years ago.

Status:Open
Priority:Normal
Assignee:-
Category:Data Provider/PostGIS
Affected QGIS version:3.0.3 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:27039

Description

When importing a layer that needed some schema tweaks (specifically to change the geom to a plain 'geometry' to avoid Polygon vs MultiPolygon errors... I wanted to turn off layer overwriting.

The ImportIntoPostGIS processing tool passes the overwrite option to
qgsvectorlayerexporter which passes it to
QgsPostgresProvider::createEmptyLayer

but as you can see here https://github.com/qgis/QGIS/blob/0a325f1eda4054418e8d31bfc1d33d87cbdc2c0f/src/providers/postgres/qgspostgresprovider.cpp#L3878 and then https://github.com/qgis/QGIS/blob/0a325f1eda4054418e8d31bfc1d33d87cbdc2c0f/src/providers/postgres/qgspostgresprovider.cpp#L3893 the PostGIS driver only uses the overwrite flag to skip dropping the existing table (good), but not to avoid creating a new table (bad) - and this naturally fails.

This seems to be the case even very far back in history, so perhaps this should be considered a feature request rather than a bug?

Also available in: Atom PDF