Skip to content

Commit

Permalink
allow multiple result sets for sap and mssql
Browse files Browse the repository at this point in the history
  • Loading branch information
Lars-Erik Roald committed Jan 17, 2024
1 parent d0f3211 commit 6d19dc6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 33 deletions.
16 changes: 12 additions & 4 deletions src/mssql/wrapQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,24 @@ function wrapQuery(connection) {
function runQuery(query, onCompleted) {
var params = query.parameters;
var sql = query.sql();
log.emitQuery({sql, parameters: params});
log.emitQuery({ sql, parameters: params });

runOriginalQuery.call(connection, sql, params, onInnerCompleted);
let result = [];

function onInnerCompleted(err, rows) {
function onInnerCompleted(err, rows, hasMore) {
if (err) {
onCompleted(err);
return;
}
result.push(rows);
if (!hasMore) {

if (result.length === 1)
onCompleted(null, result[0]);
else
onCompleted(null, result);
}
else
onCompleted(null, rows);
}
}

Expand Down
24 changes: 0 additions & 24 deletions src/sap/wrapQuery.js

This file was deleted.

7 changes: 2 additions & 5 deletions src/table/executeQueries/resolveExecuteQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@ function resolveExecuteQuery(query) {
}

function onCompleted(err, rows) {
if (!err) {
var lastIndex = rows.length - 1;
if (!Array.isArray(rows[0]) && Array.isArray(rows[lastIndex]))
rows = rows[lastIndex];
if (!err)
success(rows);
} else
else
failed(err);
}
}
Expand Down

0 comments on commit 6d19dc6

Please sign in to comment.