You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This request comes after #35030 and after a brief exchange with @m-kuhn.
Long story short:
when setting a default value in the properties of a vector layer, the user can use values like "5", or variables (i.e. @username) or functions (i.e. now()) and have this correctly applied on insert and on update (the latter if the proper checkbox is selected).
when using other expressions, i.e. containing field names, QGIS now warns the user with the following message:
"using fields in a default value expression only works if "apply default value on update" is checked"
meaning that the expression will be applied only on update and not on insert.
Is not difficult to create a use case where it make sense to have the default expression to work both for inserts and updates. At the moment if this default option have the "using fields in a default value expression..." checked then it won't work on inserts.
Take a point vector
Create a column "common_name"
Create a column "scientific_name"
Crete a default value for "scientific_name" as following
CASE
WHEN
"common_name" = 'Cork Oak'
THEN
'Quercus suber'
WHEN
"common_name" = 'Eucalypt'
THEN
'Eucalyptus globulus'
ELSE
'no match'
END
I guess you see the point, is a use case where it make sense have the default expression work for both inserts and updates... a specie can be wrongly defined on insert and then is needed to fix is common and scientific names
Start add points and in the "common_name" field write 'Cork Oak' or 'Eucalypt' , you'll se the "scientific_name" column be filled as expected immediately, but then the computed values are discarded after saving if "using fields in a default value expression..." is checked.
If is not checked it will works for inserts but not for updates.
The text was updated successfully, but these errors were encountered:
I have been pointed that with "using fields in a default value expression..." checked it should also work on insert. So maybe it is me or maybe this is not working anymore on master (which I'm using).
This request comes after #35030 and after a brief exchange with @m-kuhn.
Long story short:
when setting a default value in the properties of a vector layer, the user can use values like "5", or variables (i.e. @username) or functions (i.e. now()) and have this correctly applied on insert and on update (the latter if the proper checkbox is selected).
when using other expressions, i.e. containing field names, QGIS now warns the user with the following message:
"using fields in a default value expression only works if "apply default value on update" is checked"
meaning that the expression will be applied only on update and not on insert.
Is not difficult to create a use case where it make sense to have the default expression to work both for inserts and updates. At the moment if this default option have the "using fields in a default value expression..." checked then it won't work on inserts.
Take a point vector
Create a column "common_name"
Create a column "scientific_name"
Crete a default value for "scientific_name" as following
I guess you see the point, is a use case where it make sense have the default expression work for both inserts and updates... a specie can be wrongly defined on insert and then is needed to fix is common and scientific names
Start add points and in the "common_name" field write 'Cork Oak' or 'Eucalypt' , you'll se the "scientific_name" column be filled as expected immediately, but then the computed values are discarded after saving if "using fields in a default value expression..." is checked.
If is not checked it will works for inserts but not for updates.
The text was updated successfully, but these errors were encountered: