Skip to content

Commit 20600ff

Browse files
iteufelojourmel
authored andcommitted
Fixed MSSQl boolean support
1 parent b01ed3a commit 20600ff

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

Diff for: lib/dialects/mssql/index.js

+29
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,35 @@ var templateChecks = require('../../utils/templateChecks');
77

88
var Dialect = module.exports = function(builder) {
99
builder.options.valuesPrefix = '@';
10+
11+
builder._pushValue = function(value) {
12+
if (_.isUndefined(value) || _.isNull(value)) {
13+
return 'null';
14+
} else if (_.isBoolean(value)) {
15+
return String(Number(value));
16+
} else if (_.isNumber(value)) {
17+
return String(value);
18+
} else if (_.isString(value) || _.isDate(value)) {
19+
if (this.options.separatedValues) {
20+
var placeholder = this._getPlaceholder();
21+
22+
if (this.options.namedValues) {
23+
this._values[placeholder] = value;
24+
} else {
25+
this._values.push(value);
26+
}
27+
28+
return this._wrapPlaceholder(placeholder);
29+
} else {
30+
if (_.isDate(value)) value = value.toISOString();
31+
32+
return '\'' + value + '\'';
33+
}
34+
} else {
35+
throw new Error('Wrong value type "' + (typeof value) + '"');
36+
}
37+
};
38+
1039
BaseDialect.call(this, builder);
1140

1241
this.blocks.set('limit', function(params) {

0 commit comments

Comments
 (0)