Permalink
Browse files

fixes and tests around excute procedure support

  • Loading branch information...
xdenser committed Dec 14, 2011
1 parent 64fc333 commit fa18daa8990a09109fcbbf39243bb7a6ef67f518
Showing with 47 additions and 10 deletions.
  1. +9 −5 src/fb-bindings-statement.cc
  2. +38 −5 tests/def/test-prepared-stmt.js
@@ -74,7 +74,8 @@ Handle<Value>
FBStatement *fb_stmt = ObjectWrap::Unwrap<FBStatement>(args.This());
- FBResult::set_params(fb_stmt->in_sqlda, args);
+ Handle<Value> sp_res = FBResult::set_params(fb_stmt->in_sqlda, args);
+ if(!sp_res->IsUndefined()) return scope.Close(sp_res);
if(fb_stmt->retres)
{
@@ -174,12 +175,12 @@ void FBStatement::EIO_After_Exec(uv_work_t *req)
event = error_symbol;
}
else
- {
+ {*/
argv[0] = Local<Value>::New(Null());
argc = 1;
event = result_symbol;
- }
- */
+ // }
+
if(fb_stmt->statement_type != isc_info_sql_stmt_select)
{
//Local<Object> js_result_row;
@@ -233,7 +234,10 @@ Handle<Value>
String::New("Could not allocate memory.")));
}
- FBResult::set_params(fb_stmt->in_sqlda, args);
+ //FBResult::set_params(fb_stmt->in_sqlda, args);
+ Handle<Value> sp_res = FBResult::set_params(fb_stmt->in_sqlda, args);
+ if(!sp_res->IsUndefined()) return scope.Close(sp_res);
+
if(fb_stmt->retres)
{
@@ -20,6 +20,16 @@ module.exports = testCase({
this.conn = new fb_binding.createConnection();
this.conn.connectSync(cfg.db, cfg.user, cfg.password, cfg.role);
this.conn.querySync('create table PREPARED_TEST_TABLE ( test_field1 INT, test_field2 VARCHAR(10))');
+ var sql = 'create or alter procedure TEST_PROC(\n'+
+ '"INPUT" varchar(25))\n'+
+ 'returns (\n'+
+ '"OUTPUT" varchar(25))\n'+
+ 'as\n'+
+ 'BEGIN\n'+
+ ' output = input;\n'+
+ ' suspend;\n'+
+ 'END\n';
+ this.conn.querySync(sql);
callback();
},
tearDown: function(callback){
@@ -28,6 +38,7 @@ module.exports = testCase({
var conn = new fb_binding.createConnection();
conn.connectSync(cfg.db, cfg.user, cfg.password, cfg.role);
conn.querySync('drop table PREPARED_TEST_TABLE');
+ conn.querySync('drop procedure TEST_PROC');
conn.disconnect();
callback();
},
@@ -112,14 +123,36 @@ module.exports = testCase({
var self = this;
stmt.once('result',function(err){
test.ok(!err,'no error on insert');
- var stmt = self.conn.prepareSync('select test_field2 from PREPARED_TEST_TABLE');
- stmt.exec();
- stmt.once('result',function(err){
+ var stmt1 = self.conn.prepareSync('select test_field2 from PREPARED_TEST_TABLE');
+ stmt1.once('result',function(err){
test.ok(!err,'no error on select');
- var row = stmt.fetchSync("all",false);
+ var row = stmt1.fetchSync("all",false);
test.equal(data[1],row[0][0],'returned data equal');
test.done();
});
+ stmt1.exec();
});
- }
+
+ },
+ execProcSync:function(test){
+ test.expect(2);
+ var stmt = this.conn.prepareSync('execute procedure TEST_PROC(?)');
+ var data = 'test';
+ var res = stmt.execSync(data);
+ test.ok(res,'have result');
+ test.equal(res.OUTPUT,data,'returned data equal');
+ test.done();
+ },
+ execProcAsync:function(test){
+ test.expect(2);
+ var stmt = this.conn.prepareSync('execute procedure TEST_PROC(?)');
+ var data = 'testAsync';
+ stmt.exec(data);
+ stmt.once('result',function(err,res){
+ test.ok(res,'have result');
+ test.equal(res.OUTPUT,data,'returned data equal');
+ test.done();
+ });
+ }
+
});

0 comments on commit fa18daa

Please sign in to comment.