Skip to content

Commit

Permalink
Merge 57fba27 into 5417cac
Browse files Browse the repository at this point in the history
  • Loading branch information
oitTim committed Sep 21, 2019
2 parents 5417cac + 57fba27 commit bbbff20
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/dialects/oracledb/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,13 @@ Client_Oracledb.prototype._query = function(connection, obj) {
? response.rows.rowsAffected
: response.rowsAffected;

//added for outBind parameter
if (obj.method === 'raw' && outBinds.length > 0) {
return resolver({
response: outBinds,
});
}

if (obj.method === 'update') {
const modifiedRowsCount = obj.rowsAffected.length || obj.rowsAffected;
const updatedObjOutBinding = [];
Expand Down
46 changes: 46 additions & 0 deletions test/integration/builder/additional.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,52 @@ module.exports = function(knex) {
});
});

if (knex.client.driverName === 'oracledb') {
const oracledb = require('oracledb');
describe('test oracle stored procedures', function() {
it('create stored procedure', function() {
return knex
.raw(
`
CREATE OR REPLACE PROCEDURE SYSTEM.multiply (X IN NUMBER, Y IN NUMBER, OUTPUT OUT NUMBER)
IS
BEGIN
OUTPUT := X * Y;
END;`
)
.then(function(result) {
expect(result).to.be.an('array');
});
});

it('get outbound values from stored procedure', function() {
const bindVars = {
x: 6,
y: 7,
output: {
dir: oracledb.BIND_OUT,
},
};
return knex
.raw('BEGIN SYSTEM.MULTIPLY(:x, :y, :output); END;', bindVars)
.then(function(result) {
expect(result[0]).to.be.ok;
expect(result[0]).to.equal('42');
});
});

it('drop stored procedure', function() {
const bindVars = { x: 6, y: 7 };
return knex
.raw('drop procedure SYSTEM.MULTIPLY', bindVars)
.then(function(result) {
expect(result).to.be.ok;
expect(result).to.be.an('array');
});
});
});
}

it('should allow renaming a column', function() {
let countColumn;
switch (knex.client.driverName) {
Expand Down

0 comments on commit bbbff20

Please sign in to comment.