Bug report #16419
Virtual layers SQL output fields without alias raise errors
|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|
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:
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:
ST_Area("landcover"."geometry") AS area
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)