Comparing version 1.6.0 to 1.7.0
@@ -54,3 +54,3 @@ // Generated by CoffeeScript 1.7.1 | ||
BulkLoad.prototype.addColumn = function(name, type, options) { | ||
var column; | ||
var column, _ref, _ref1, _ref2; | ||
if (options == null) { | ||
@@ -73,2 +73,11 @@ options = {}; | ||
}; | ||
if ((type.id & 0x30) === 0x20) { | ||
column.length = (_ref = column.length) != null ? _ref : typeof type.resolveLength === "function" ? type.resolveLength(column) : void 0; | ||
} | ||
if (type.hasPrecision) { | ||
column.precision = (_ref1 = column.precision) != null ? _ref1 : typeof type.resolvePrecision === "function" ? type.resolvePrecision(column) : void 0; | ||
} | ||
if (type.hasScale) { | ||
column.scale = (_ref2 = column.scale) != null ? _ref2 : typeof type.resolveScale === "function" ? type.resolveScale(column) : void 0; | ||
} | ||
this.columns.push(column); | ||
@@ -95,4 +104,8 @@ return this.columnsByName[name] = column; | ||
c = _ref[i]; | ||
c.value = row[arr ? i : c.objName]; | ||
_results.push(c.type.writeParameterData(this.rowsData, c, this.options)); | ||
_results.push(c.type.writeParameterData(this.rowsData, { | ||
length: c.length, | ||
scale: c.scale, | ||
precision: c.precision, | ||
value: row[arr ? i : c.objName] | ||
}, this.options)); | ||
} | ||
@@ -99,0 +112,0 @@ return _results; |
@@ -254,3 +254,3 @@ // Generated by CoffeeScript 1.7.1 | ||
buffer.writeUInt8(parameter.precision); | ||
return buffer.writeUInt8(this.resolveScale(parameter)); | ||
return buffer.writeUInt8(parameter.scale); | ||
}, | ||
@@ -261,3 +261,3 @@ writeParameterData: function(buffer, parameter) { | ||
sign = parameter.value < 0 ? 0 : 1; | ||
value = Math.round(Math.abs(parameter.value * Math.pow(10, this.resolveScale(parameter)))); | ||
value = Math.round(Math.abs(parameter.value * Math.pow(10, parameter.scale))); | ||
if (parameter.precision <= 9) { | ||
@@ -324,3 +324,3 @@ buffer.writeUInt8(5); | ||
buffer.writeUInt8(parameter.precision); | ||
return buffer.writeUInt8(this.resolveScale(parameter)); | ||
return buffer.writeUInt8(parameter.scale); | ||
}, | ||
@@ -331,3 +331,3 @@ writeParameterData: function(buffer, parameter) { | ||
sign = parameter.value < 0 ? 0 : 1; | ||
value = Math.round(Math.abs(parameter.value * Math.pow(10, this.resolveScale(parameter)))); | ||
value = Math.round(Math.abs(parameter.value * Math.pow(10, parameter.scale))); | ||
if (parameter.precision <= 9) { | ||
@@ -416,10 +416,10 @@ buffer.writeUInt8(5); | ||
buffer.writeUInt8(this.id); | ||
return buffer.writeInt32LE(this.resolveLength(parameter)); | ||
return buffer.writeInt32LE(parameter.length); | ||
}, | ||
writeParameterData: function(buffer, parameter) { | ||
if (parameter.value != null) { | ||
buffer.writeInt32LE(this.resolveLength(parameter)); | ||
buffer.writeInt32LE(parameter.length); | ||
return buffer.writeBuffer(parameter.value); | ||
} else { | ||
return buffer.writeInt32LE(this.resolveLength(parameter)); | ||
return buffer.writeInt32LE(parameter.length); | ||
} | ||
@@ -680,3 +680,46 @@ } | ||
hasCollation: true, | ||
dataLengthLength: 2 | ||
dataLengthLength: 2, | ||
maximumLength: 8000, | ||
declaration: function(parameter) { | ||
var length; | ||
if (parameter.length) { | ||
length = parameter.length; | ||
} else if (parameter.value != null) { | ||
length = parameter.value.toString().length || 1; | ||
} else if (parameter.value === null && !parameter.output) { | ||
length = 1; | ||
} else { | ||
length = this.maximumLength; | ||
} | ||
if (length < this.maximumLength) { | ||
return "char(" + length + ")"; | ||
} else { | ||
return "char(" + this.maximumLength + ")"; | ||
} | ||
}, | ||
resolveLength: function(parameter) { | ||
if (parameter.length != null) { | ||
return parameter.length; | ||
} else if (parameter.value != null) { | ||
if (Buffer.isBuffer(parameter.value)) { | ||
return parameter.value.length || 1; | ||
} else { | ||
return parameter.value.toString().length || 1; | ||
} | ||
} else { | ||
return this.maximumLength; | ||
} | ||
}, | ||
writeTypeInfo: function(buffer, parameter) { | ||
buffer.writeUInt8(this.id); | ||
buffer.writeUInt16LE(parameter.length); | ||
return buffer.writeBuffer(new Buffer([0x00, 0x00, 0x00, 0x00, 0x00])); | ||
}, | ||
writeParameterData: function(buffer, parameter) { | ||
if (parameter.value != null) { | ||
return buffer.writeUsVarbyte(parameter.value, 'ascii'); | ||
} else { | ||
return buffer.writeUInt16LE(NULL); | ||
} | ||
} | ||
}, | ||
@@ -749,3 +792,46 @@ 0xE7: { | ||
hasCollation: true, | ||
dataLengthLength: 2 | ||
dataLengthLength: 2, | ||
maximumLength: 4000, | ||
declaration: function(parameter) { | ||
var length; | ||
if (parameter.length) { | ||
length = parameter.length; | ||
} else if (parameter.value != null) { | ||
length = parameter.value.toString().length || 1; | ||
} else if (parameter.value === null && !parameter.output) { | ||
length = 1; | ||
} else { | ||
length = this.maximumLength; | ||
} | ||
if (length < this.maximumLength) { | ||
return "nchar(" + length + ")"; | ||
} else { | ||
return "nchar(" + this.maximumLength + ")"; | ||
} | ||
}, | ||
resolveLength: function(parameter) { | ||
if (parameter.length != null) { | ||
return parameter.length; | ||
} else if (parameter.value != null) { | ||
if (Buffer.isBuffer(parameter.value)) { | ||
return (parameter.value.length / 2) || 1; | ||
} else { | ||
return parameter.value.toString().length || 1; | ||
} | ||
} else { | ||
return this.maximumLength; | ||
} | ||
}, | ||
writeTypeInfo: function(buffer, parameter) { | ||
buffer.writeUInt8(this.id); | ||
buffer.writeUInt16LE(parameter.length * 2); | ||
return buffer.writeBuffer(new Buffer([0x00, 0x00, 0x00, 0x00, 0x00])); | ||
}, | ||
writeParameterData: function(buffer, parameter) { | ||
if (parameter.value != null) { | ||
return buffer.writeUsVarbyte(parameter.value, 'ucs2'); | ||
} else { | ||
return buffer.writeUInt16LE(NULL); | ||
} | ||
} | ||
}, | ||
@@ -792,3 +878,3 @@ 0xF1: { | ||
buffer.writeUInt8(this.id); | ||
return buffer.writeUInt8(this.resolveScale(parameter)); | ||
return buffer.writeUInt8(parameter.scale); | ||
}, | ||
@@ -801,4 +887,4 @@ writeParameterData: function(buffer, parameter) { | ||
parameter.value.setUTCDate(1); | ||
time = (+parameter.value / 1000 + ((_ref = parameter.value.nanosecondDelta) != null ? _ref : 0)) * Math.pow(10, this.resolveScale(parameter)); | ||
switch (this.resolveScale(parameter)) { | ||
time = (+parameter.value / 1000 + ((_ref = parameter.value.nanosecondDelta) != null ? _ref : 0)) * Math.pow(10, parameter.scale); | ||
switch (parameter.scale) { | ||
case 0: | ||
@@ -879,3 +965,3 @@ case 1: | ||
buffer.writeUInt8(this.id); | ||
return buffer.writeUInt8(this.resolveScale(parameter)); | ||
return buffer.writeUInt8(parameter.scale); | ||
}, | ||
@@ -889,4 +975,4 @@ writeParameterData: function(buffer, parameter) { | ||
time.setUTCDate(1); | ||
time = (+time / 1000 + ((_ref = parameter.value.nanosecondDelta) != null ? _ref : 0)) * Math.pow(10, this.resolveScale(parameter)); | ||
switch (this.resolveScale(parameter)) { | ||
time = (+time / 1000 + ((_ref = parameter.value.nanosecondDelta) != null ? _ref : 0)) * Math.pow(10, parameter.scale); | ||
switch (parameter.scale) { | ||
case 0: | ||
@@ -950,3 +1036,3 @@ case 1: | ||
buffer.writeUInt8(this.id); | ||
return buffer.writeUInt8(this.resolveScale(parameter)); | ||
return buffer.writeUInt8(parameter.scale); | ||
}, | ||
@@ -960,5 +1046,5 @@ writeParameterData: function(buffer, parameter) { | ||
time.setUTCDate(1); | ||
time = (+time / 1000 + ((_ref = parameter.value.nanosecondDelta) != null ? _ref : 0)) * Math.pow(10, this.resolveScale(parameter)); | ||
time = (+time / 1000 + ((_ref = parameter.value.nanosecondDelta) != null ? _ref : 0)) * Math.pow(10, parameter.scale); | ||
offset = -parameter.value.getTimezoneOffset(); | ||
switch (this.resolveScale(parameter)) { | ||
switch (parameter.scale) { | ||
case 0: | ||
@@ -965,0 +1051,0 @@ case 1: |
@@ -33,3 +33,3 @@ { | ||
], | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"main": "./lib/tedious.js", | ||
@@ -36,0 +36,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
194693
5661