Bug report #17013

"Vector Grid" column names need to be quotes otherwise direct output to PostgreSQL fails

Added by George Rodrigues da Cunha Silva 12 days ago. Updated 5 days ago.

Status:Open
Priority:Normal
Assignee:Victor Olaya
Category:Processing/Core
Affected QGIS version:2.18.11 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No

Description

When using the "Vector grid" utility, with the output to PostgreSQL, it will not run, because xmin and xmax is a reserved column word on PostgreSQL.

The output column names should be configurable or at least change when the destination is postgresql.

History

#1 Updated by Nyall Dawson 11 days ago

  • Status changed from Open to Feedback

Please test on a recent 3.0 snapshot - there's been underlying changes which likely have fixed this.

#2 Updated by Giovanni Manghi 10 days ago

Nyall Dawson wrote:

Please test on a recent 3.0 snapshot - there's been underlying changes which likely have fixed this.

this should anyway be fixed also in the LTR release. Would a change in the column names be enough?

#3 Updated by George Rodrigues da Cunha Silva 7 days ago

A simple change in the columns name will suffice.

#4 Updated by Nyall Dawson 7 days ago

Except we can't change the column names in the stable release without possibly breaking existing working models.... Rather we need to ensure that the column names are correctly escaped via ""

#5 Updated by Giovanni Manghi 5 days ago

Nyall Dawson wrote:

Please test on a recent 3.0 snapshot - there's been underlying changes which likely have fixed this.

Hi Nyall,
on master I'm getting

Algorithm 'Create grid (polygon)' starting...
Input parameters: {'CRS': 'EPSG:3763', 'EXTENT': '-59184.51646631695,-55438.2333398374,-146053.81655070916,-142415.1852382089', 'HOVERLAY': 0.0, 'HSPACING': 1000.0, 'OUTPUT': <QgsProcessingOutputLayerDefinition {'sink':memory:, 'createOptions': {'fileEncoding': 'System'}}>, 'TYPE': 0, 'VOVERLAY': 0.0, 'VSPACING': 1000.0}

Traceback (most recent call last): File "C:/OSGEO4~1/apps/qgis-dev/./python/plugins\processing\algs\qgis\GridPolygon.py", line 152, in processAlgorithm sink, width, height, originX, originY, hSpacing, vSpacing, hOverlay, vOverlay, feedback) File "C:/OSGEO4~1/apps/qgis-dev/./python/plugins\processing\algs\qgis\GridPolygon.py", line 193, in _rectangleGrid ft.setGeometry(QgsGeometry.fromPolygon([polyline])) TypeError: QgsGeometry.fromPolygon(): argument 1 has unexpected type 'list'

#6 Updated by Giovanni Manghi 5 days ago

  • Subject changed from Vector Grid does not allow direct output to PostgreSQL to "Vector Grid" column names need to be quotes otherwise direct output to PostgreSQL fails
  • Operating System deleted (linux mint)
  • Status changed from Feedback to Open

Nyall Dawson wrote:

Except we can't change the column names in the stable release without possibly breaking existing working models.... Rather we need to ensure that the column names are correctly escaped via ""

gave it a try but was not able to fix it. Of course not my ballpark (not my game).

#7 Updated by Nyall Dawson 5 days ago

Traceback (most recent call last): File "C:/OSGEO4~1/apps/qgis-dev/./python/plugins\processing\algs\qgis\GridPolygon.py", line 152, in processAlgorithm sink, width, height, originX, originY, hSpacing, vSpacing, hOverlay, vOverlay, feedback) File "C:/OSGEO4~1/apps/qgis-dev/./python/plugins\processing\algs\qgis\GridPolygon.py", line 193, in _rectangleGrid ft.setGeometry(QgsGeometry.fromPolygon([polyline])) TypeError: QgsGeometry.fromPolygon(): argument 1 has unexpected type 'list'

Hmm - works fine here, and in the unit tests locally and on Travis. That error looks like a problem with your build (since QgsGeometry.fromPolygon() does require list inputs). Can you try deleting your build folder and rebuilding?

#8 Updated by Giovanni Manghi 5 days ago

Hmm - works fine here, and in the unit tests locally and on Travis. That error looks like a problem with your build (since QgsGeometry.fromPolygon() does require list inputs). Can you try deleting your build folder and rebuilding?

that message is from master in osgeo4w (updated today), but I can indeed try compile myself also on Linux.

#9 Updated by Giovanni Manghi 5 days ago

Hmm - works fine here, and in the unit tests locally and on Travis. That error looks like a problem with your build (since QgsGeometry.fromPolygon() does require list inputs). Can you try deleting your build folder and rebuilding?

works on linux (ubuntu 16.04) if outputting to temp layer or shapefile, while when trying to postgis:

Traceback (most recent call last): File "/usr/share/qgis/python/plugins/processing/algs/qgis/GridPolygon.py", line 152, in processAlgorithm sink, width, height, originX, originY, hSpacing, vSpacing, hOverlay, vOverlay, feedback) File "/usr/share/qgis/python/plugins/processing/algs/qgis/GridPolygon.py", line 195, in _rectangleGrid sink.addFeature(ft, QgsFeatureSink.FastInsert) AttributeError: 'NoneType' object has no attribute 'addFeature'

#10 Updated by Giovanni Manghi 5 days ago

works on linux (ubuntu 16.04) if outputting to temp layer or shapefile, while when trying to postgis:

Traceback (most recent call last): File "/usr/share/qgis/python/plugins/processing/algs/qgis/GridPolygon.py", line 152, in processAlgorithm sink, width, height, originX, originY, hSpacing, vSpacing, hOverlay, vOverlay, feedback) File "/usr/share/qgis/python/plugins/processing/algs/qgis/GridPolygon.py", line 195, in _rectangleGrid sink.addFeature(ft, QgsFeatureSink.FastInsert) AttributeError: 'NoneType' object has no attribute 'addFeature'

Nyall, I guess should I file a separate ticket about this, agree?

Also available in: Atom PDF