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

Persist empty relation as null instead of omitting it from the ES document #78

Merged
merged 1 commit into from Apr 17, 2024

Conversation

limenet
Copy link
Member

@limenet limenet commented Apr 17, 2024

Given

$this->relationAttributesWithDefault($element, [
    ProductIndex::ATTRIBUTE_VARIETY => Product::FIELD_VARIETY,
]),

where variety is a one-to-one/many relation,

the resulting Elasticsearch when variety is empty is

{
}

and when variety points to object ID 91

{
  "variety": 91
}

.

This PR changes the case where the relation is empty to

{
  "variety": null
}

in order to make the behavior consistent with other methods in this trait. Hence this is considered a bugfix and not a breaking change.


Resolve #77

@limenet limenet added the bug Something isn't working label Apr 17, 2024
@limenet limenet self-assigned this Apr 17, 2024
@limenet limenet changed the title persist empty relation as null instead of omitting it from the ES document Persist empty relation as null instead of omitting it from the ES document Apr 17, 2024
@limenet limenet merged commit f92db57 into main Apr 17, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Empty relations are skipped
1 participant