Bug report #16419
Virtual layers SQL output fields without alias raise errors
Status: | Feedback | ||
---|---|---|---|
Priority: | Normal | ||
Assignee: | - | ||
Category: | DB Manager | ||
Affected QGIS version: | master | Regression?: | No |
Operating System: | Easy fix?: | No | |
Pull Request or Patch supplied: | No | Resolution: | |
Crashes QGIS or corrupts data: | No | Copied to github as #: | 24328 |
Description
Calculated fields inside Virtual Layers SQL queries (through DB Manager) must have an alias otherwise it raises errors.
The problem is that it can't be deduced from the error message.
As an example:
SELECT
ST_Area("landcover"."geometry")
FROM "landcover"
will raise the message "Query preparation error on SELECT "ST_Area("comuni"."geometry")" FROM _tview LIMIT 1: near ""."": syntax error"
(you can see it in the vlayer.png image attachment)
The query works fine if an alias is added:
SELECT
ST_Area("landcover"."geometry") AS area
FROM "landcover"
I guess that the fix could be to use the field function as a string and use it for the output field name (as DBs do)
History
#1 Updated by Giovanni Manghi over 7 years ago
- Easy fix? set to No
- Regression? set to No
#2 Updated by Giovanni Manghi over 5 years ago
- Status changed from Open to Feedback
Please check if this issue is still valid on QGIS 3.4.5 or 3.6.