Bug report #15935
"Default values" expression widget doesn't allow aggregate functions nor list layer fields
|Affected QGIS version:||master||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:||wontfix|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||23851|
Using the expression widget to set a "default value" for a field, I encounter some weird limitations:
- fields are not proposed in the "fields and values" list in the expression dialog: only NULL is shown
- trying to use aggregate functions returns an error : Cannot use aggregate function in this context
you can write in the textbox an expression like maximum("myfield") + 1 and it works.
A bug? (I try on a scratch layer)
#2 Updated by Harrissou Santanna almost 4 years ago
Then, it seems there's a bug in the implementation: the expression in my previous message (maximum("myfield") + 1) uses a field of the current layer, actually the field being "widgeted"; this successfully creates a serial field.
But i can also use expression like maximum("anotherfieldofthecurrentlayer")+1. The only limitation is that the expression can not be set within the expression builder but it works.
I'm on master 37c43df