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

Fix multi-statement error handling in node query result #3340

Merged
merged 1 commit into from
Apr 22, 2024
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
4 changes: 4 additions & 0 deletions tools/nodejs_api/src_cpp/include/node_query_result.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ class NodeQueryResultGetNextQueryResultAsyncWorker : public Napi::AsyncWorker {
void Execute() override {
try {
auto nextResult = currQueryResult->queryResult->getNextQueryResult();
if (!nextResult->isSuccess()) {
SetError(nextResult->getErrorMessage());
return;
}
nextQueryResult->SetQueryResult(nextResult, false);
} catch (const std::exception& exc) {
SetError(std::string(exc.what()));
Expand Down
14 changes: 14 additions & 0 deletions tools/nodejs_api/test/test_connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,20 @@ describe("Query", function () {
]);
assert.deepEqual(results, [[{ 1: 1 }], [{ 2: 2 }], [{ 3: 3 }]]);
});

it("should throw error if one of the multiple queries is invalid", async function () {
try {
await conn.query(`
RETURN 1;
RETURN 2;
MATCH (a:dog) RETURN COUNT(*);
`);
assert.fail("No error thrown when one of the multiple queries is invalid.");
} catch (e) {
assert.equal(e.message, "Binder exception: Table dog does not exist.");
}
}
);
});

describe("Timeout", function () {
Expand Down
Loading