Skip to content

Fix streaming trailing rows with msnodesqlv8 driver - #1108

Closed
mtriff wants to merge 2 commits into
tediousjs:masterfrom
mtriff:master
Closed

mtriff wants to merge 2 commits into
tediousjs:masterfrom
mtriff:master

Conversation

@mtriff

@mtriff mtriff commented Sep 25, 2020

Copy link
Copy Markdown
Contributor

What this does: Streams all row results when querying with msnodesqlv8.

Currently, trailing rows are not properly returned in all cases (i.e. when pausing/resuming every 10 rows, with 102 rows, the last row is never returned).

msnodesqlv8 fires a row event before emitting the column events with the column data, Currently, mssql returns the previous row each time it handles a row event (so that the row will have been populated by the column events). Usually, the final row was handled in the done event handler. However, in the above scenario, the last column event gets handled after the done event handler.

This change switches from emitting rows on the msnodesqlv8 row events to emitting them after the final column event for that row is processed. This is similar to how msnodesqlv8 implements sequilize support.

Comment thread README.md
### Microsoft / Contributors Node V8 Driver for Node.js for SQL Server

**Requires Node.js 0.12.x or newer. Windows only.** This driver is not part of the default package and must be installed separately by `npm install msnodesqlv8`. To use this driver, use this require syntax: `const sql = require('mssql/msnodesqlv8')`.
**Requires Node.js 0.12.x or newer. Windows/Linux only.** This driver is not part of the default package and must be installed separately by `npm install msnodesqlv8`. To use this driver, use this require syntax: `const sql = require('mssql/msnodesqlv8')`.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is clearly a bit old 🤦 - please can you update the node js version to v10+

Comment thread test/common/tests.js
assert.strictEqual(rows, 0)
started = true
req.resume()
}, 1000)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

waiting a second in the test suite to run this test is quite a long time. I'm not convinced we need to delay the start of the stream because this functionality is tested in other tests.

Comment thread test/common/tests.js
if (rows >= 102) {
assert.strictEqual(rows, 102)
}
if (rows % 10 == 0) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to test the pause/resume functionality in this test? This is covered by other tests.

@dhensby

dhensby commented Sep 25, 2020

Copy link
Copy Markdown
Collaborator

There are some linting failures, please can you resolve those?

Also, I think it's best we target the 6 branch so that this can be released in the next stable version (which I will probably do later this month or early October).

Thanks a lot for the PR and digging into this issue!

@dhensby

dhensby commented Sep 25, 2020

Copy link
Copy Markdown
Collaborator

@mtriff as you've made the PR from your master branch, rather than breaking your master by rebasing your work onto the 6 branch, I've opened a new PR with your commits cherry-picked and I've made the changes from the review.

Thanks for this

@dhensby dhensby closed this Sep 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants