Commit 457146dd by Konstantin Käfer

rename run to get to indicate that it returns the next value. The .run()…

rename run to get to indicate that it returns the next value. The .run() function (yet to be implemented) automatically resets the query before each run and does not return result rows
parent a3877d66
......@@ -35,7 +35,7 @@ void Statement::Init(v8::Handle<Object> target) {
constructor_template->SetClassName(String::NewSymbol("Statement"));
NODE_SET_PROTOTYPE_METHOD(constructor_template, "bind", Bind);
NODE_SET_PROTOTYPE_METHOD(constructor_template, "run", Run);
NODE_SET_PROTOTYPE_METHOD(constructor_template, "get", Get);
NODE_SET_PROTOTYPE_METHOD(constructor_template, "finalize", Finalize);
target->Set(v8::String::NewSymbol("Statement"),
......@@ -299,27 +299,27 @@ int Statement::EIO_AfterBind(eio_req *req) {
Handle<Value> Statement::Run(const Arguments& args) {
Handle<Value> Statement::Get(const Arguments& args) {
HandleScope scope;
Statement* stmt = ObjectWrap::Unwrap<Statement>(args.This());
OPTIONAL_ARGUMENT_FUNCTION(0, callback);
RowBaton* baton = new RowBaton(stmt, callback);
stmt->Schedule(EIO_BeginRun, baton);
stmt->Schedule(EIO_BeginGet, baton);
return args.This();
}
void Statement::EIO_BeginRun(Baton* baton) {
void Statement::EIO_BeginGet(Baton* baton) {
assert(!baton->stmt->locked);
assert(!baton->stmt->finalized);
assert(baton->stmt->prepared);
baton->stmt->locked = true;
eio_custom(EIO_Run, EIO_PRI_DEFAULT, EIO_AfterRun, baton);
eio_custom(EIO_Get, EIO_PRI_DEFAULT, EIO_AfterGet, baton);
}
int Statement::EIO_Run(eio_req *req) {
int Statement::EIO_Get(eio_req *req) {
RowBaton* baton = static_cast<RowBaton*>(req->data);
Statement* stmt = baton->stmt;
Database* db = stmt->db;
......@@ -347,7 +347,7 @@ int Statement::EIO_Run(eio_req *req) {
return 0;
}
int Statement::EIO_AfterRun(eio_req *req) {
int Statement::EIO_AfterGet(eio_req *req) {
HandleScope scope;
RowBaton* baton = static_cast<RowBaton*>(req->data);
Statement* stmt = baton->stmt;
......
......@@ -148,10 +148,10 @@ protected:
static int EIO_Bind(eio_req *req);
static int EIO_AfterBind(eio_req *req);
static Handle<Value> Run(const Arguments& args);
static void EIO_BeginRun(Baton* baton);
static int EIO_Run(eio_req *req);
static int EIO_AfterRun(eio_req *req);
static Handle<Value> Get(const Arguments& args);
static void EIO_BeginGet(Baton* baton);
static int EIO_Get(eio_req *req);
static int EIO_AfterGet(eio_req *req);
static void GetRow(Result::Row* row, sqlite3_stmt* stmt);
static Local<Array> RowToJS(Result::Row* row);
......
......@@ -23,7 +23,7 @@ exports['test simple prepared statement'] = function(beforeExit) {
var run = false;
var db = new sqlite3.Database(':memory:');
db.prepare("CREATE TABLE foo (text bar)")
.run(function(err) {
.get(function(err) {
if (err) throw err;
run = true;
})
......@@ -46,7 +46,7 @@ exports['test inserting and retrieving rows'] = function(beforeExit) {
Step(
function() {
db.prepare("CREATE TABLE foo (txt text, num int, flt float, blb blob)").run(this);
db.prepare("CREATE TABLE foo (txt text, num int, flt float, blb blob)").get(this);
},
function(err) {
if (err) throw err;
......@@ -58,7 +58,7 @@ exports['test inserting and retrieving rows'] = function(beforeExit) {
i,
i * Math.PI
// null (SQLite sets this implicitly)
).run(group());
).get(group());
}
},
function(err, rows) {
......@@ -68,7 +68,7 @@ exports['test inserting and retrieving rows'] = function(beforeExit) {
var group = this.group();
for (var i = 0; i < count + 5; i++) {
stmt.run(group());
stmt.get(group());
}
},
function(err, rows) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment