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) { ...@@ -35,7 +35,7 @@ void Statement::Init(v8::Handle<Object> target) {
constructor_template->SetClassName(String::NewSymbol("Statement")); constructor_template->SetClassName(String::NewSymbol("Statement"));
NODE_SET_PROTOTYPE_METHOD(constructor_template, "bind", Bind); 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); NODE_SET_PROTOTYPE_METHOD(constructor_template, "finalize", Finalize);
target->Set(v8::String::NewSymbol("Statement"), target->Set(v8::String::NewSymbol("Statement"),
...@@ -299,27 +299,27 @@ int Statement::EIO_AfterBind(eio_req *req) { ...@@ -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; HandleScope scope;
Statement* stmt = ObjectWrap::Unwrap<Statement>(args.This()); Statement* stmt = ObjectWrap::Unwrap<Statement>(args.This());
OPTIONAL_ARGUMENT_FUNCTION(0, callback); OPTIONAL_ARGUMENT_FUNCTION(0, callback);
RowBaton* baton = new RowBaton(stmt, callback); RowBaton* baton = new RowBaton(stmt, callback);
stmt->Schedule(EIO_BeginRun, baton); stmt->Schedule(EIO_BeginGet, baton);
return args.This(); return args.This();
} }
void Statement::EIO_BeginRun(Baton* baton) { void Statement::EIO_BeginGet(Baton* baton) {
assert(!baton->stmt->locked); assert(!baton->stmt->locked);
assert(!baton->stmt->finalized); assert(!baton->stmt->finalized);
assert(baton->stmt->prepared); assert(baton->stmt->prepared);
baton->stmt->locked = true; 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); RowBaton* baton = static_cast<RowBaton*>(req->data);
Statement* stmt = baton->stmt; Statement* stmt = baton->stmt;
Database* db = stmt->db; Database* db = stmt->db;
...@@ -347,7 +347,7 @@ int Statement::EIO_Run(eio_req *req) { ...@@ -347,7 +347,7 @@ int Statement::EIO_Run(eio_req *req) {
return 0; return 0;
} }
int Statement::EIO_AfterRun(eio_req *req) { int Statement::EIO_AfterGet(eio_req *req) {
HandleScope scope; HandleScope scope;
RowBaton* baton = static_cast<RowBaton*>(req->data); RowBaton* baton = static_cast<RowBaton*>(req->data);
Statement* stmt = baton->stmt; Statement* stmt = baton->stmt;
......
...@@ -148,10 +148,10 @@ protected: ...@@ -148,10 +148,10 @@ protected:
static int EIO_Bind(eio_req *req); static int EIO_Bind(eio_req *req);
static int EIO_AfterBind(eio_req *req); static int EIO_AfterBind(eio_req *req);
static Handle<Value> Run(const Arguments& args); static Handle<Value> Get(const Arguments& args);
static void EIO_BeginRun(Baton* baton); static void EIO_BeginGet(Baton* baton);
static int EIO_Run(eio_req *req); static int EIO_Get(eio_req *req);
static int EIO_AfterRun(eio_req *req); static int EIO_AfterGet(eio_req *req);
static void GetRow(Result::Row* row, sqlite3_stmt* stmt); static void GetRow(Result::Row* row, sqlite3_stmt* stmt);
static Local<Array> RowToJS(Result::Row* row); static Local<Array> RowToJS(Result::Row* row);
......
...@@ -23,7 +23,7 @@ exports['test simple prepared statement'] = function(beforeExit) { ...@@ -23,7 +23,7 @@ exports['test simple prepared statement'] = function(beforeExit) {
var run = false; var run = false;
var db = new sqlite3.Database(':memory:'); var db = new sqlite3.Database(':memory:');
db.prepare("CREATE TABLE foo (text bar)") db.prepare("CREATE TABLE foo (text bar)")
.run(function(err) { .get(function(err) {
if (err) throw err; if (err) throw err;
run = true; run = true;
}) })
...@@ -46,7 +46,7 @@ exports['test inserting and retrieving rows'] = function(beforeExit) { ...@@ -46,7 +46,7 @@ exports['test inserting and retrieving rows'] = function(beforeExit) {
Step( Step(
function() { 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) { function(err) {
if (err) throw err; if (err) throw err;
...@@ -58,7 +58,7 @@ exports['test inserting and retrieving rows'] = function(beforeExit) { ...@@ -58,7 +58,7 @@ exports['test inserting and retrieving rows'] = function(beforeExit) {
i, i,
i * Math.PI i * Math.PI
// null (SQLite sets this implicitly) // null (SQLite sets this implicitly)
).run(group()); ).get(group());
} }
}, },
function(err, rows) { function(err, rows) {
...@@ -68,7 +68,7 @@ exports['test inserting and retrieving rows'] = function(beforeExit) { ...@@ -68,7 +68,7 @@ exports['test inserting and retrieving rows'] = function(beforeExit) {
var group = this.group(); var group = this.group();
for (var i = 0; i < count + 5; i++) { for (var i = 0; i < count + 5; i++) {
stmt.run(group()); stmt.get(group());
} }
}, },
function(err, rows) { 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