Bug report #21895
Default values and expression calculator not working together
|Affected QGIS version:||3.4.3||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||29710|
While trying to work around #21892 I encountered the following.
To replicate (in a GeoPackage - probably not format specific):
1) Create a new field of type Integer called whatever (_MY_FIELD here)
2) Use the Layer Properties -> Attributes Form to set a default value of 0 on _MY_FIELD, and tick the "Apply default on update" (this is the bug!)
3) Now, use expression calculator to UPDATE _MY_FIELD with any numerical value (fid will do).
Result = _MY_FIELD only has values of "0".
If you uncheck the "Apply default on update" then the update of the field will work as expected.