-
Notifications
You must be signed in to change notification settings - Fork 109
chore(filter): Add a switch statement #1108
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
chore(filter): Add a switch statement #1108
Conversation
In the filter function a switch statement is added so that it is clear to the reader what happens when the arguments are of various lengths
|
🤖 I detect that the PR title and the commit message differ and there's only one commit. To use the PR title for the commit history, you can use Github's automerge feature with squashing, or use -- conventional-commit-lint bot |
…ithub.com/danieljbruce/nodejs-datastore into 1096-filter-function-should-have-a-switch
src/query.ts
Outdated
| case 1: { | ||
| if (isFilter(propertyOrFilter)) { | ||
| this.entityFilters.push(propertyOrFilter); | ||
| } else { |
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 think the else branch should be removed here (operatorOrValue and value are not provided)
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.
ok
src/query.ts
Outdated
| case 2: { | ||
| this.filters.push({ | ||
| name: (propertyOrFilter as String).trim(), | ||
| op: '=' as Operator, |
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.
as Operator is probably not needed here?
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.
yup
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.
LGTM with a couple nits
Remove the else block, it should never happen anyway because if it does then the user is misusing the function
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.
Nice!
In the filter function a switch statement is added so that it is clear to the reader what happens when the arguments are of various lengths.
Fixes #1096