Bug report #18512
Addind map layers in expression builder adds layer ID
|Affected QGIS version:||3.0.0||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||26400|
Currently, i can write in expression builder something like get_feature( 'streets', 'name','main st') to return a 'main st' from the streets layer.
To improve the UX, a "map layers" group is added and now I no longer have to remember what was the exact name of the layer; double-click is good enough.
Issue is that instead of the recognizable streets, i get the layer Id which is something like streets_5d217552_8e06_41de_8b23_e3e9fc27d094, very hard to identify and which imho does not ease expression review.
Could be handier to add the layer name, instead?
#2 Updated by Harrissou Santanna about 2 years ago
This is the explanation i suspected.
Sorry i do not have QGIS nearby to check but does the list then show "streets" more than once if i have many layers named that way?
I've always wondered how was the layer identified when there are multiple occurrences of the name. And i understand that in the current state of me writing get_feature( 'streets', 'name','main st'), this is fragile and i can get unexpected results whether there is 0 or more than one "streets" layer name?
If we keep the current layer ID system maybe add ability to see layer name when hovering over the id in the expression?
If we go the other route i was suggesting (Disclaimer: I don't know what i'm writing about, the work it requires and if it's worth it or possible) could we imagine some kind of system in which we would have an internal expression using layer Id and a displayed and good looking one which will use layer name. The first one will be the one really executed.
We could later imagine that the layer name is updated automatically in the displayed expression if ever it changes (thanks to the id).
Thinking aside: If i remove a layer from the project, my expression is broken, regardless i use layer name or layer ID (0 streets layer). Do we have a place to notify user whether there is a broken expression in the project, other than the red icon of expression or data-defined buttons? Should I open a feature request?