Handle null database values as null in translations #479
+3
−3
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.
This pull requests is originated from the conversation on #474 where @vencelkatai and i agreed on finding a way to have an implementation that satisfies our use cases and also keep the library consistent.
Changes
getTranslation
method to check if the raw attribute value isnull
usingself::getAttributeFromArray
. If the attribute isnull
, it will now treat the translation asnull
instead of falling back to an empty string.Why This Change Is Needed
Previously,
null
values in the database were treated inconsistently, being returned as empty strings in translations. This behavior could lead to unexpected results in applications that differentiate betweennull
and empty strings. By aligning the translation output with the underlying database value, this change ensures more predictable and intuitive behavior.Next Steps
Please @freekmurze and @vencelkatai review the changes and share your feedback. If the approach aligns with expectations, I’ll proceed with further documentation or additional tests if necessary.
Thank you!