Fix entity bug where the wrong properties of an entity are populated #914
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On Slack, @lognaturel identified a bug where a form field that populates an entity property is not updated if it’s changed by a new form version.
It seemed like the fields being used to parse entity properties from a submission weren't filtered to just the properties in that specific form def/schema.
Looking into it more, this was indeed the case: when looking up fields by the submission's form def id, dataset property fields were joined via the form schema, but the schema doesn't change when just the entity bindings change (but maybe it should??)
Luckily (probably because of this exact situation) the
ds_property_fields
table still has aformDefId
column, which we can go back to using for this join.(Edit - Done) Leaving in draft mode while I look into
schemaId
when it would be better to use theformDefId
Dataset.getProperties
, but it gets properties for the entire dataset and has its own ways of grouping and ordering the properties. Also, the formDefId is not always available in the query. We have a lot of tests around getting dataset properties with this function so I think it can stay the way it is.What has been done to verify that this works as intended?
Tests.
Why is this the best possible solution? Were any other approaches considered?
Since the form schema doesn't change when just the dataset bindings change, we can't use the
schemaId
when joining dataset properties and form fields. Switch back to using the more specificformDefId
that we still have ondataset_property_fields
.Maybe the schema should change in these cases.
How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
Addresses a bug.
Does this change require updates to the API documentation? If so, please update docs/api.md as part of this PR.
No.
Before submitting this PR, please make sure you have:
make test-full
and confirmed all checks still pass OR confirm CircleCI build passes