mssql-cr-layer 2.0.18 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/index.js +7 -16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mssql-cr-layer",
3
- "version": "2.0.18",
3
+ "version": "3.0.0",
4
4
  "description": "A MS SQL Server interface layer for common requests",
5
5
  "repository": "andrglo/mssql-cr-layer",
6
6
  "author": {
@@ -22,7 +22,7 @@
22
22
  "devDependencies": {
23
23
  "chai": "^4.3.7",
24
24
  "coveralls": "^3.1.1",
25
- "eslint": "^8.35.0",
25
+ "eslint": "^8.45.0",
26
26
  "eslint-config-google": "^0.14.0",
27
27
  "mocha": "^10.2.0",
28
28
  "nyc": "^15.1.0"
package/src/index.js CHANGED
@@ -241,21 +241,9 @@ MssqlCrLayer.prototype.query = function(statement, params, options) {
241
241
  const param = params[key]
242
242
  if (typeof param === 'object' && !(param instanceof Date)) {
243
243
  input[key] = param && param.value !== void 0 ? param.value : null
244
- // Fix crash when inform a Date value and pass a string
245
- if (
246
- input[key] !== null &&
247
- (param.type === 'date' || param.type === 'datetime') &&
248
- !(input[key] instanceof Date)
249
- ) {
250
- input[key] = new Date(input[key])
251
- }
252
244
  ps.input(key, getType(input[key], param))
253
245
  } else {
254
246
  input[key] = param !== void 0 ? param : null
255
- if (input[key] instanceof Date) {
256
- // Fix mssql precision
257
- input[key] = input[key].toISOString().substring(0, 23) + '000'
258
- }
259
247
  ps.input(key, getType(input[key]))
260
248
  }
261
249
  })
@@ -272,12 +260,15 @@ MssqlCrLayer.prototype.query = function(statement, params, options) {
272
260
  })
273
261
  })
274
262
  .catch(function(error) {
275
- debug('%s %O', statement, error)
276
263
  return ps.unprepare().then(function() {
277
264
  throw error
278
265
  })
279
266
  })
280
267
  })
268
+ .catch(err => {
269
+ debug('%s %O', statement, err)
270
+ throw err
271
+ })
281
272
  }
282
273
 
283
274
  /**
@@ -318,10 +309,10 @@ function getType(value, param) {
318
309
  type = mssql.Date
319
310
  break
320
311
  case 'datetime':
321
- if (param.timezone === 'ignore') {
322
- type = mssql.DateTime2
323
- } else {
312
+ if (param.timezone === true) {
324
313
  type = mssql.DateTimeOffset
314
+ } else {
315
+ type = mssql.DateTime2
325
316
  }
326
317
  break
327
318
  case 'string':