Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default values using @snapping_result delete attributes #37359

Closed
m-kuhn opened this issue Jun 23, 2020 · 1 comment · Fixed by #37769
Closed

Default values using @snapping_result delete attributes #37359

m-kuhn opened this issue Jun 23, 2020 · 1 comment · Fixed by #37769
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter!

Comments

@m-kuhn
Copy link
Member

m-kuhn commented Jun 23, 2020

Given a point layer with an attribute name and an attribute time.
Configure the default value for the field name using the expression below. Disable (or enable) apply on update.

Expected behavior: when I add a point on top of an existing one, it will copy the name and I'm able to fine tune the fields.
Observed behavior: when I add a point on top of an existing one, it will copy the name but as soon as I edit the time, the field name is cleared.

with_variable(
  'first_snapped_point',
  array_first( @snapping_results ),
  attribute(
    get_feature_by_id(
      map_get( @first_snapped_point, 'layer' ),
      map_get( @first_snapped_point, 'feature_id' )
    ),
    'name'
  )
)
@m-kuhn m-kuhn added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Jun 23, 2020
@m-kuhn
Copy link
Member Author

m-kuhn commented Jun 23, 2020

This issue is composed of a couple of interleaved issues:

  1. The variable @snapping_result is only populated to pre-evaluate default values before they are sent to the attribute form. If the attribute form later on updates / recalculates default values, map tool capture expression scope is lost.
  2. The functionality to update depending fields as they are filled. This functionality is expected only to work when "apply on update" is toggled (at least that's what the warning on the layer properties -> attribute form dialog suggests). This functionality is still enabled also when apply on update is disabled.
  3. Bonus issue: the dependencies on the layer are calculated based on the required fields. The expression function attribute() propagates that it depends on all fields. So if any other field changes, this field will depend on it and be recalculated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant