Skip to content

Commit

Permalink
Avoid checking exact arguments length
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferriel Melarpis committed Jul 24, 2017
1 parent 30f1d6c commit f3ff60a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
12 changes: 5 additions & 7 deletions lib/CustomMySQL.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,16 @@ var CustomMySQL = function () {
key: 'build',
value: function build() {

var args = Array.from(arguments);
this._cache = Array.from(arguments);

if (args.length === 1 && _squel3.default.cls.isSquelBuilder(args[0])) {
if (_squel3.default.cls.isSquelBuilder(this._cache[0])) {

var query = args[0].toParam();
var query = this._cache[0].toParam();

this._cache = [query.text, query.values];

return this;
this._cache[0] = query.text;
this._cache.splice(1, 0, query.values);
}

this._cache = args;
return this;
}
}, {
Expand Down
12 changes: 5 additions & 7 deletions src/CustomMySQL.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,16 @@ export default class CustomMySQL {

build () {

const args = Array.from(arguments);
this._cache = Array.from(arguments);

if (args.length === 1 && squel.cls.isSquelBuilder(args[0])) {
if (squel.cls.isSquelBuilder(this._cache[0])) {

const query = args[0].toParam();
const query = this._cache[0].toParam();

this._cache = [query.text, query.values];

return this;
this._cache[0] = query.text;
this._cache.splice(1, 0, query.values);
}

this._cache = args;
return this;
}

Expand Down

0 comments on commit f3ff60a

Please sign in to comment.