Bug report #17013

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

Added by George Rodrigues da Cunha Silva over 3 years ago. Updated over 1 year ago.

Status:Closed
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:end of life
Crashes QGIS or corrupts data:No Copied to github as #:24912

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 over 3 years 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 over 3 years 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 over 3 years ago

A simple change in the columns name will suffice.

#4 Updated by Nyall Dawson over 3 years 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 over 3 years 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 over 3 years ago

  • Status changed from Feedback to Open
  • Operating System deleted (linux mint)
  • 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

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 over 3 years 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 over 3 years 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 over 3 years 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 over 3 years 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?

#11 Updated by Giovanni Manghi over 1 year ago

  • Status changed from Open to Closed
  • Resolution set to end of life

End of life notice: QGIS 2.18 LTR

Source:
http://blog.qgis.org/2019/03/09/end-of-life-notice-qgis-2-18-ltr/

QGIS 3.4 has recently become our new Long Term Release (LTR) version. This is a major step in our history – a long term release version based on the massive updates, library upgrades and improvements that we carried out in the course of the 2.x to 3x upgrade cycle.

We strongly encourage all users who are currently using QGIS 2.18 LTR as their preferred QGIS release to migrate to QGIS 3.4. This new LTR version will receive regular bugfixes for at least one year. It also includes hundreds of new functions, usability improvements, bugfixes, and other goodies. See the relevant changelogs for a good sampling of all the new features that have gone into version 3.4

Most plugins have been either migrated or incorporated into the core QGIS code base.

We strongly discourage the continued use of QGIS 2.18 LTR as it is now officially unsupported, which means we’ll not provide any bug fix releases for it.

You should also note that we intend to close all bug tickets referring to the now obsolete LTR version. Original reporters will receive a notification of the ticket closure and are encouraged to check whether the issue persists in the new LTR, in which case they should reopen the ticket.

If you would like to better understand the QGIS release roadmap, check out our roadmap page! It outlines the schedule for upcoming releases and will help you plan your deployment of QGIS into an operational environment.

The development of QGIS 3.4 LTR has been made possible by the work of hundreds of volunteers, by the investments of companies, professionals, and administrations, and by continuous donations and financial support from many of you. We sincerely thank you all and encourage you to collaborate and support the project even more, for the long term improvement and sustainability of the QGIS project.

Also available in: Atom PDF