Skip to content

Commit

Permalink
fix: filtering with an empty array as a value causes an error (#715)
Browse files Browse the repository at this point in the history
* fix: filtering with an empty array as a value causes an error

* fix: linter error

* fix: remove code duplication

* fix: Unnecessary 'else' after 'return'  no-else-return linter error
  • Loading branch information
zacharygolba committed Jul 11, 2017
1 parent 0f406b5 commit 6b3547f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/packages/database/query/index.js
Expand Up @@ -195,17 +195,17 @@ class Query<+T: any> extends Promise {
}

if (Array.isArray(value)) {
if (value.length > 1) {
this.snapshots.push([
not ? 'whereNotIn' : 'whereIn',
[key, value]
]);
} else {
if (value.length === 1) {
return {
...obj,
[key]: value[0]
};
}

this.snapshots.push([
not ? 'whereNotIn' : 'whereIn',
[key, value]
]);
} else if (value === null) {
this.snapshots.push([
not ? 'whereNotNull' : 'whereNull',
Expand Down

1 comment on commit 6b3547f

@zacharygolba
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From #715

Please sign in to comment.