Skip to content

Core Data: getEditedEntityRecord raw attributes regression #69236

@Mamaduka

Description

@Mamaduka

This commit had a subtle behavior change. Previously, the REST API could return a value for a field of...

{
  "raw": null,
  "rendered": "Some default value"
}

Core data would make the raw value available when using getEditedEntityRecord(). So you'd see null.

After this commit, the function returns the full { raw, rendered } pair. The reason is that lodash's get only returns the default value if the expression evaluates to undefined. But the null coalescing operator this was replaced with returns the rhs for both undefined and null.

Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place.

https://lodash.com/docs/4.17.15#get


This caused a subtle bug in a project I maintain. While it's been two years, I think it still would be worth adjusting? Otherwise, you can have a field that is listed as in rawAttributes sometimes return the object value.

Originally posted by @TimothyBJacobs in #48310 (comment)

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions