Skip to content

Commit

Permalink
Remove confusing conditions (#1159)
Browse files Browse the repository at this point in the history
* Remove unreachable code

* Remove redundant condition

Every path with `!this.values` results in `false` regardless of `this.binary`.
  • Loading branch information
charmander authored and brianc committed Dec 13, 2016
1 parent 48a9738 commit 981960b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
6 changes: 2 additions & 4 deletions lib/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,9 @@ Query.prototype.requiresPreparation = function() {
if(this.rows) { return true; }
//don't prepare empty text queries
if(!this.text) { return false; }
//binary should be prepared to specify results should be in binary
//unless there are no parameters
if(this.binary && !this.values) { return false; }
//prepare if there are values
return (this.values || 0).length > 0;
if(!this.values) { return false; }
return this.values.length > 0;
};


Expand Down
3 changes: 0 additions & 3 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ var prepareValue = function(val, seen) {
if(typeof val === 'object') {
return prepareObject(val, seen);
}
if (typeof val === 'undefined') {
throw new Error('SQL queries with undefined where clause option');
}
return val.toString();
};

Expand Down

0 comments on commit 981960b

Please sign in to comment.