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

Add support for Oracle Implicit Results #8050

Merged
merged 3 commits into from
Aug 8, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 5 additions & 1 deletion src/driver/oracle/OracleQueryRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export class OracleQueryRunner extends BaseQueryRunner implements QueryRunner {

const result = new QueryResult();

result.raw = raw.rows || raw.outBinds || raw.rowsAffected;
result.raw = raw.rows || raw.outBinds || raw.rowsAffected || raw.implicitResults;

if (raw?.hasOwnProperty('rows') && Array.isArray(raw.rows)) {
result.records = raw.rows;
Expand All @@ -211,6 +211,10 @@ export class OracleQueryRunner extends BaseQueryRunner implements QueryRunner {
result.records = raw.outBinds;
}

if (raw?.hasOwnProperty('implicitResults') && Array.isArray(raw.implicitResults)) {
result.records = raw.implicitResults;
}

if (raw?.hasOwnProperty('rowsAffected')) {
result.affected = raw.rowsAffected;
}
Expand Down
57 changes: 57 additions & 0 deletions test/functional/query-runner/implicit-results.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import "reflect-metadata";
import { Connection } from "../../../src";
import { closeTestingConnections, createTestingConnections } from "../../utils/test-utils";
import { expect } from "chai";

describe.only("query runner > implicit results", () => {
imnotjames marked this conversation as resolved.
Show resolved Hide resolved

let connections: Connection[];
before(async () => {
connections = await createTestingConnections({
entities: [__dirname + "/view/*{.js,.ts}"],
enabledDrivers: ["oracle"],
schemaCreate: true,
dropSchema: true,
});
});
after(() => closeTestingConnections(connections));

it("should return results for Oracle Stored Procedure with Implicit Results", () => Promise.all(connections.map(async connection => {
const queryRunner = connection.createQueryRunner();

// Create sample procedure with implicit results
await connection.query(`
CREATE OR REPLACE PROCEDURE TEST_IMPLICIT_RESULTS
AS
test_array dbms_sql.varchar2_table;
cur1 sys_refcursor;
BEGIN
test_array(1) := 'First';
test_array(2) := 'Second';
test_array(3) := 'Third';
OPEN cur1 FOR SELECT * FROM TABLE(test_array);
DBMS_SQL.return_result(cur1);
END;
`);

const result = await queryRunner.query(`
BEGIN
TEST_IMPLICIT_RESULTS;
END;
`);

expect(result).to.be.an('array');
expect(result).to.eql(
[
[
{ COLUMN_VALUE: 'First' },
{ COLUMN_VALUE: 'Second' },
{ COLUMN_VALUE: 'Third' },
]
]
);

await queryRunner.release();
})));

});