Bug report #19343
Comment in last line of Query in DB Manager makes "Load now!" fail
Status: | Closed | ||
---|---|---|---|
Priority: | Normal | ||
Assignee: | - | ||
Category: | DB Manager | ||
Affected QGIS version: | 2.18.21 | Regression?: | No |
Operating System: | Easy fix?: | Yes | |
Pull Request or Patch supplied: | No | Resolution: | |
Crashes QGIS or corrupts data: | No | Copied to github as #: | 27171 |
Description
If one has a SQL comment in the last line of a (PostGIS) query in the DB manager, QGIS will fail to load the layer with a syntax error hidden in the PostGIS messages log.
SQL: SELECT * FROM (SELECT row_number() over () AS _uid_,* FROM (myoriginalquery
--some comment I wrote) AS _subq_1_
) AS "subQuery_0" LIMIT 1
This is due to QGIS appending its surrounding code directly after the last character and this makes it just part of the comment
Always adding a linebreak after the user's lines should solve this:
SQL: SELECT * FROM (SELECT row_number() over () AS _uid_,* FROM (myoriginalquery
--some comment I wrote
) AS _subq_1_
) AS "subQuery_0" LIMIT 1
I would fix and test this but cannot understand the code :) It will probably apply in multiple providers:
Associated revisions
db manager: also add newline when adding a unique id field (fixes #19343)
db manager: also add newline when adding a unique id field (fixes #19343)
(cherry picked from commit 870d078479352d61edd902ab9d2ca48e98db9148)
db manager: also add newline when adding a unique id field (fixes #19343)
(cherry picked from commit 870d078479352d61edd902ab9d2ca48e98db9148)
History
#1
Updated by Jürgen Fischer about 6 years ago
- % Done changed from 0 to 100
- Status changed from Open to Closed
Applied in changeset qgis|870d078479352d61edd902ab9d2ca48e98db9148.