Skip to content

Commit

Permalink
SNOW-1769573 -Add support for describeOnly
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-pmotacki committed Nov 5, 2024
1 parent 268a58a commit 25cf8f4
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions test/integration/testExecute.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,24 +138,33 @@ describe('Execute test', function () {
);
});

it('testDescribeOnly', function (done) {
it('testDescribeOnly', async function () {
const selectWithDescribeOnly = 'SELECT 1.0::NUMBER(30,2) as C1, 2::NUMBER(38,0) AS C2, \'t3\' AS C3, 4.2::DOUBLE AS C4, \'abcd\'::BINARY(8388608) AS C5, true AS C6';

function executeQueryAndVerifyResultDependOnDescribeOnly(describeOnly) {
connection.execute({
sqlText: selectWithDescribeOnly,
describeOnly: describeOnly,
complete: (err, stmt, rows) => {
assert.strictEqual(stmt.getColumns().length, 6);
//Empty rowset in response
assert.strictEqual(rows.length, describeOnly ? 0 : 1);
done();
}
});
}

executeQueryAndVerifyResultDependOnDescribeOnly(true);
executeQueryAndVerifyResultDependOnDescribeOnly(false);
const executeQueryAndVerifyResultDependOnDescribeOnly = async (describeOnly, expectedReturnedRows) => {
return new Promise((resolve, reject) => {
connection.execute({
sqlText: selectWithDescribeOnly,
describeOnly: describeOnly,
complete: (err, stmt, rows) => {
assert.strictEqual(stmt.getColumns().length, 6);
assert.strictEqual(rows.length, expectedReturnedRows.length);
if (rows.length > 0) {
const columnsNamesInMetadata = stmt.getColumns().map(cl => cl.getName());
const columnsNames = Object.keys(rows[0]);
assert.equal(JSON.stringify(columnsNamesInMetadata), JSON.stringify(columnsNames));
assert.equal(JSON.stringify(rows), JSON.stringify(expectedReturnedRows));
}
return err ? reject(err) : resolve(rows);
}
});
}
);
};
const expectedRows = [{ 'C1': 1, 'C2': 2, 'C3': 't3', 'C4': 4.2, 'C5': { 'type': 'Buffer', 'data': [171, 205] }, 'C6': true }];
await executeQueryAndVerifyResultDependOnDescribeOnly(true, []);
await executeQueryAndVerifyResultDependOnDescribeOnly(false, expectedRows);
await executeQueryAndVerifyResultDependOnDescribeOnly(undefined, expectedRows);
});
});

Expand Down

0 comments on commit 25cf8f4

Please sign in to comment.