-
Notifications
You must be signed in to change notification settings - Fork 436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bulk Insert #176
Comments
Thanks Bret, I have found a strange behaviour. Consider this test: exports.bulkLoadError = (test) ->
config = getConfig()
connection = new Connection(config)
connection.on('connect', (err) ->
test.ifError(err)
bulk = connection.newBulkLoad('#tmpTestTable2', (err, rowCount) ->
console.log err, rowCount
test.ifError(err)
test.strictEqual(rowCount, 0, 'Incorrect number of rows inserted.');
# temporary disabled to let ECONNRESET error to be thrown
#connection.close()
)
bulk.addColumn('x', TYPES.Int, { nullable: false })
bulk.addColumn('y', TYPES.Int, { nullable: false })
# create temporary table
request = new Request("CREATE TABLE #tmpTestTable2 ([id] int)", (err) ->
test.ifError(err)
bulk.addRow({ x: 1, y: 1 })
connection.execBulkLoad(bulk)
)
connection.execSqlBatch(request)
)
connection.on('end', (info) ->
test.done()
)
connection.on('error', (err) ->
console.error("ERROR: #{err.stack}")
)
connection.on('debug', (text) ->
console.log(text)
) As you can see, I'm trying to insert data to table that has a different structure of columns. I would exepect an error here, but strange things happen. First of all the connection hangs up immediately once you send the
What documentation 2.2.7.5 says:
But the problem is, there is no preceding ERROR token. If this is a normal behaviour, Tedious should always check for Before we start making a changes, I would like to ask you to check it. Thanks. |
I can definitely repro this, thank you. I'm thinking you're right that Tedious should always check the I suppose we need to decide what that error message should look like since it's essentially an unknown error. I assume the best way to handle this would be to check for if token.sqlError && !@request.error
@request.error = RequestError('An unknown error has occurred.', 'UNKNOWN') Do we need to makeup a mock ERROR token and emit an In certain contexts, like bulk load, we could re-write the message before sending it to the callback in order to give hints as to the likely cause, while still indicating that the true cause is unknown. Thoughts? |
I believe we don't need an Your solution is fine by me. |
Okay, I'll try to get to it today or tomorrow. |
Fixed and published as |
👍 Thanks. |
Any reason to leave this open, or tagged as |
I just wanted to give people a chance to look at it. It can be closed now. |
@bretcope, any thoughts on that? tediousjs/node-mssql#81 |
Since it's a significant new feature which I didn't do via pull request, I just wanted to open an issue here for a few days to announce that bulk insert is now implemented.
I added experimental support a couple weeks ago, and I believe we've worked out all the kinks since then, so tonight I wrote a test, documented it, and declared the API stable. It's published as
1.4.0
.I've added it to Tedium, which is the generator-based wrapper I've been working on. @patriksimek if it seems within the scope of node-mssql, again, the API should be stable now, so feel free.
If there are any questions, please add them to this thread.
The text was updated successfully, but these errors were encountered: