You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
We must standardize the treatment of null and undefined for fields in the database.
Nowadays we don't have tests that validate undefined fields in the toEntity method, but as reported in another issue, a null field is a value, and undefined is the lack of value, and we have encountered many problems when a key is undefined, as reported: #36 and #38
Describe the solution you'd like
Add unit tests to validate the rules related to returning null or undefined, using a validation that whenever the field is null or undefined, the field itself should be returned (i.e., not doing any conversion from null to undefined or undefined to null), as reported: #37 (comment)
Describe alternatives you've considered
I considered using checker.isEmpty, since #36 is a breaking change, so it wouldn't be a problem to have multiple breaking changes in a single PR, but the problem is that empty array ([]) and empty string ("") would also be considered empty, which could generate other problems.
Additional context
I believe that this issue would be better solved if it went up in a PR together with issues #36 and #38
The text was updated successfully, but these errors were encountered:
I believe the solution should be as follows:
Has null or undefined been saved to the database? then the parser must return the value itself, without doing any checking.
Was saved empty array? Returns the empty array.
Using checker.isEmpty null, undefined, {} or "" values will be returned by themselves, without being
converted to null or undefined and without being passed to the parser.
BREAKING CHANGE: This can change the way a value that does not exist in the collection is
undefined in the application that uses the lib.
A null value is returned as null, but an
undefined is passed to the parser and can return a different value.
Instead of "undefined",
undefined will be returned, causing breaking changes in systems that expect "undefined" with a
string type.
herbsjs#36 and herbsjs#39
…y of entities
When an entity is empty (null, undefined or {}) it must return this value, without converting to
null
BREAKING CHANGE: These values were being converted to null previously, this could affect systems
that use the lib and do some if checking if it is equal to null, and with this change, it could
return undefined.
herbsjs#39
Is your feature request related to a problem? Please describe.
We must standardize the treatment of null and undefined for fields in the database.
Nowadays we don't have tests that validate undefined fields in the toEntity method, but as reported in another issue, a null field is a value, and undefined is the lack of value, and we have encountered many problems when a key is undefined, as reported: #36 and #38
Describe the solution you'd like
Add unit tests to validate the rules related to returning null or undefined, using a validation that whenever the field is null or undefined, the field itself should be returned (i.e., not doing any conversion from null to undefined or undefined to null), as reported: #37 (comment)
Describe alternatives you've considered
I considered using
checker.isEmpty
, since #36 is a breaking change, so it wouldn't be a problem to have multiple breaking changes in a single PR, but the problem is that empty array ([]
) and empty string (""
) would also be considered empty, which could generate other problems.Additional context
I believe that this issue would be better solved if it went up in a PR together with issues #36 and #38
The text was updated successfully, but these errors were encountered: