Skip to content
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

Result calling issue #640

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions lib/connection/result/result.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function Result(options) {
this._returnedRows = data.returned;
this._totalRows = data.total;
this._statementTypeId = data.statementTypeId;
Logger.getInstance().trace("The result.js is called. QueryId is:", this._queryId);

// if no chunk headers were specified, but a query-result-master-key (qrmk)
// was specified, build the chunk headers from the qrmk
Expand Down
49 changes: 49 additions & 0 deletions test/unit/result_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const connOption = require("../integration/connectionOptions");
const snowflake = require('snowflake-sdk');
const assert = require('assert');
const testUtil = require("../integration/testUtil");

snowflake.configure({logLevel:"TRACE"});

describe.only("test and log how many result.js called for each execution",function (){
let connection = snowflake.createConnection(connOption.valid);
connection.connect(
function (err, conn)
{
if (err)
{
console.error('Unable to connect: ' + err.message);
}
else
{
console.log('Successfully connected to Snowflake');
}
}
)

it('Run Select 1 query', function (done)
{
connection.execute({
sqlText: "select 1",
complete: function (err, stmt)
{
testUtil.checkError(err);
var stream = stmt.streamRows();
Copy link
Collaborator

Choose a reason for hiding this comment

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

you are reading from stream here - so you need to set streamResult to true as described in https://docs.snowflake.com/en/developer-guide/node-js/nodejs-driver-consume#streaming-results

Copy link
Collaborator Author

@sfc-gh-ext-simba-jy sfc-gh-ext-simba-jy Sep 20, 2023

Choose a reason for hiding this comment

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

I set this because this is a testing code. Although I set streamResult:true option, the driver still called result.js twice. I remove the stream and just added simple check.

var rowCount = 0;
stream.on('data', function ()
{
rowCount++;
});
stream.on('error', function (err)
{
testUtil.checkError(err);
});
stream.on('end', function ()
{
done();
});
}
});
});
})

Loading