Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
What this does:

<!-- Describe the PR -->

Related issues:

<!-- Provide links to any related issues or issues being closed by this PR -->

Pre/Post merge checklist:

- [ ] Update change log
5 changes: 5 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
v8.0.0 (2021-??-??)
-------------------
[change] Updated to latest Tedious 14 ((#1318)[https://github.com/tediousjs/node-mssql/pull/1318])
[change] Errors for bad bulk load parameters have slightly different error messages ((#1318)[https://github.com/tediousjs/node-mssql/pull/1318])

v7.2.1 (2021-08-19)
-------------------
[fix] Fix issue with bulk insert of dates ((#1298)[https://github.com/tediousjs/node-mssql/pull/1298])
Expand Down
1 change: 1 addition & 0 deletions lib/tedious/connection-pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class ConnectionPool extends BaseConnectionPool {
}

debug('connection(%d): established', IDS.get(tedious))
this.collation = tedious.databaseCollation
resolveOnce(tedious)
})
IDS.add(tedious, 'Connection')
Expand Down
14 changes: 3 additions & 11 deletions lib/tedious/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,26 +334,18 @@ class Request extends BaseRequest {
bulk.addColumn(col.name, getTediousType(col.type), { nullable: col.nullable, length: col.length, scale: col.scale, precision: col.precision })
}

for (const row of table.rows) {
try {
bulk.addRow(row)
} catch (e) {
return handleError(true, connection, e)
}
}

if (table.create) {
const objectid = table.temporary ? `tempdb..[${table.name}]` : table.path
const req = new tds.Request(`if object_id('${objectid.replace(/'/g, '\'\'')}') is null ${table.declare()}`, err => {
if (err) return done(err)

connection.execBulkLoad(bulk)
connection.execBulkLoad(bulk, table.rows)
})
this._setCurrentRequest(req)

connection.execSqlBatch(req)
} else {
connection.execBulkLoad(bulk)
connection.execBulkLoad(bulk, table.rows)
}
})
})
Expand Down Expand Up @@ -645,7 +637,7 @@ class Request extends BaseRequest {
const param = this.parameters[name]

try {
param.value = getTediousType(param.type).validate(param.value)
param.value = getTediousType(param.type).validate(param.value, this.parent.collation)
} catch (e) {
e.message = `Validation failed for parameter '${name}'. ${e.message}`
const err = new RequestError(e, 'EPARAM')
Expand Down
Loading