Virtual layers SQL output fields without alias raise errors #24328
Labels
Bug
Either a bug report, or a bug fix. Let's hope for the latter!
DB Manager
Relating to the DB Manager core plugin
Feedback
Waiting on the submitter for answers
Author Name: Giovanni Allegri (@giohappy)
Original Redmine Issue: 16419
Affected QGIS version: master
Redmine category:db_manager
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)
The text was updated successfully, but these errors were encountered: