Comparing version 3.6.0 to 3.6.1
{ | ||
"name": "squel", | ||
"version": "3.6.0", | ||
"main": "squel.js", | ||
"ignore": [ | ||
"**/.*", | ||
"Gruntfile.js", | ||
"node_modules", | ||
"public", | ||
"test", | ||
"src", | ||
"docs" | ||
] | ||
"name": "squel", | ||
"version": "3.6.1", | ||
"main": "squel.js", | ||
"ignore": [ | ||
"**/.*", | ||
"Gruntfile.js", | ||
"node_modules", | ||
"public", | ||
"test", | ||
"src", | ||
"docs" | ||
] | ||
} |
{ | ||
"name": "squel", | ||
"description": "SQL query string builder", | ||
"version": "3.6.0", | ||
"author": "Ramesh Nair <ram@hiddentao.com> (http://www.hiddentao.com/)", | ||
"contributors": [ | ||
"Ramesh Nair <ram@hiddentao.com> (http://www.hiddentao.com/)", | ||
"nl_0 <nl.imbecile@gmail.com>" | ||
], | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"coffee-script": "~1.6.3", | ||
"uglify-js": "1.3.x", | ||
"chai": "1.5.x", | ||
"mocha": "1.9.x", | ||
"sinon": "1.6.x", | ||
"underscore": "1.4.x", | ||
"grunt-contrib-coffee": "~0.7.0", | ||
"time-grunt": "~0.1.1", | ||
"grunt-contrib-clean": "~0.5.0", | ||
"load-grunt-tasks": "~0.1.0", | ||
"grunt": "~0.4.1", | ||
"grunt-contrib-uglify": "~0.2.4", | ||
"grunt-mocha-test": "~0.6.3", | ||
"grunt-shell": "~0.4.0", | ||
"grunt-text-replace": "~0.3.11" | ||
}, | ||
"keywords": [ | ||
"sql", | ||
"database", | ||
"rdbms" | ||
], | ||
"main": "squel", | ||
"scripts": { | ||
"test": "grunt", | ||
"build": "grunt" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/hiddentao/squel.git" | ||
}, | ||
"engines": { | ||
"node": ">= 0.6.0" | ||
} | ||
} | ||
"name": "squel", | ||
"description": "SQL query string builder", | ||
"version": "3.6.1", | ||
"author": "Ramesh Nair <ram@hiddentao.com> (http://www.hiddentao.com/)", | ||
"contributors": [ | ||
"Ramesh Nair <ram@hiddentao.com> (http://www.hiddentao.com/)", | ||
"nl_0 <nl.imbecile@gmail.com>" | ||
], | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"coffee-script": "~1.6.3", | ||
"uglify-js": "1.3.x", | ||
"chai": "1.5.x", | ||
"mocha": "1.9.x", | ||
"sinon": "1.6.x", | ||
"underscore": "1.4.x", | ||
"grunt-contrib-coffee": "~0.7.0", | ||
"time-grunt": "~0.1.1", | ||
"grunt-contrib-clean": "~0.5.0", | ||
"load-grunt-tasks": "~0.1.0", | ||
"grunt": "~0.4.1", | ||
"grunt-contrib-uglify": "~0.2.4", | ||
"grunt-mocha-test": "~0.6.3", | ||
"grunt-shell": "~0.4.0", | ||
"grunt-text-replace": "~0.3.11" | ||
}, | ||
"keywords": [ | ||
"sql", | ||
"database", | ||
"rdbms" | ||
], | ||
"main": "squel", | ||
"scripts": { | ||
"test": "grunt", | ||
"build": "grunt" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/hiddentao/squel.git" | ||
}, | ||
"engines": { | ||
"node": ">= 0.6.0" | ||
} | ||
} |
58
squel.js
@@ -288,6 +288,13 @@ /* | ||
BaseBuilder.prototype._formatValueAsParam = function(value) { | ||
if (value instanceof cls.QueryBuilder && value.isNestable()) { | ||
return "" + value; | ||
var _this = this; | ||
if (Array.isArray(value)) { | ||
return value.map(function(v) { | ||
return _this._formatValueAsParam(v); | ||
}); | ||
} else { | ||
return this._formatCustomValue(value); | ||
if (value instanceof cls.QueryBuilder && value.isNestable()) { | ||
return "" + value; | ||
} else { | ||
return this._formatCustomValue(value); | ||
} | ||
} | ||
@@ -297,2 +304,3 @@ }; | ||
BaseBuilder.prototype._formatValue = function(value, formattingOptions) { | ||
var _this = this; | ||
if (formattingOptions == null) { | ||
@@ -302,11 +310,18 @@ formattingOptions = {}; | ||
value = this._formatCustomValue(value); | ||
if (null === value) { | ||
value = "NULL"; | ||
} else if ("boolean" === typeof value) { | ||
value = value ? "TRUE" : "FALSE"; | ||
} else if (value instanceof cls.QueryBuilder) { | ||
value = "(" + value + ")"; | ||
} else if ("number" !== typeof value) { | ||
value = this._escapeValue(value); | ||
value = formattingOptions.dontQuote ? "" + value : "'" + value + "'"; | ||
if (Array.isArray(value)) { | ||
value = value.map(function(v) { | ||
return _this._formatValue(v); | ||
}); | ||
value = "(" + (value.join(', ')) + ")"; | ||
} else { | ||
if (null === value) { | ||
value = "NULL"; | ||
} else if ("boolean" === typeof value) { | ||
value = value ? "TRUE" : "FALSE"; | ||
} else if (value instanceof cls.QueryBuilder) { | ||
value = "(" + value + ")"; | ||
} else if ("number" !== typeof value) { | ||
value = this._escapeValue(value); | ||
value = formattingOptions.dontQuote ? "" + value : "'" + value + "'"; | ||
} | ||
} | ||
@@ -403,3 +418,3 @@ return value; | ||
Expression.prototype._toString = function(node, paramMode) { | ||
var child, nodeStr, p, params, str, _i, _j, _len, _len1, _ref, _ref1; | ||
var child, inStr, nodeStr, params, str, _i, _len, _ref; | ||
if (paramMode == null) { | ||
@@ -417,13 +432,10 @@ paramMode = false; | ||
if (!paramMode) { | ||
child.para = Array.isArray(child.para) ? "(" + (child.para.join(', ')) + ")" : this._formatValue(child.para); | ||
nodeStr = nodeStr.replace('?', child.para); | ||
nodeStr = nodeStr.replace('?', this._formatValue(child.para)); | ||
} else { | ||
params = params.concat(this._formatValueAsParam(child.para)); | ||
if (Array.isArray(child.para)) { | ||
_ref1 = child.para; | ||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { | ||
p = _ref1[_j]; | ||
params.push(this._formatValueAsParam(p)); | ||
} | ||
} else { | ||
params.push(this._formatValueAsParam(child.para)); | ||
inStr = Array.apply(null, new Array(child.para.length)).map(function() { | ||
return '?'; | ||
}); | ||
nodeStr = nodeStr.replace('?', "(" + (inStr.join(', ')) + ")"); | ||
} | ||
@@ -1551,3 +1563,3 @@ } | ||
squel = { | ||
VERSION: '3.6.0', | ||
VERSION: '3.6.1', | ||
expr: function() { | ||
@@ -1554,0 +1566,0 @@ return new cls.Expression; |
69427
1583