-
-
Notifications
You must be signed in to change notification settings - Fork 53
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
feat: added support for comparator of null values with equals and notEquals #310
base: main
Are you sure you want to change the base?
Conversation
return compareDates(expected, actual) === 0 | ||
return compareDates(expected as unknown as Date, actual as unknown as Date) === 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added null to equals in DateQuery.
This would cause people to guess that a null value is coming here.
However, since null values cannot be retrieved by getComparatorsForValue, the function for comparison cannot be used.
The null value is now handled before the call.
So the null value will not appear here,
The unknown type is used to overwrite the Date to suppress type errors.
if (comparatorName === "equals" && expectedValue === null) { | ||
return actualValue === null | ||
} | ||
|
||
if (comparatorName === "notEquals" && expectedValue === null) { | ||
return actualValue !== null | ||
} | ||
|
||
// If an entity doesn't have any value for the property | ||
// is being queried for, treat it as non-matching. | ||
if (actualValue == null) { | ||
return false | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed control when actualValue is null.
Addes comparison if comparatorName is equals or notEquals and expectedValue is null.
This control prevents null values from entering getComparatorsForValue.
75f3794
to
da06da0
Compare
Hi, thank you for developing a great library.
I would like to compare null with equals and notEquals in the Where clause, but it seems that it is not currently supported.
I see the same reported in issue #228.
I wanted this feature and implemented it, what do you think?