Permalink
Browse files

bugfix: one() throws an exception when a record isn't found

  • Loading branch information...
1 parent 3089b7f commit 8cecdda142736b3cae1f9cb408642aa3732611ab @jvinet committed Jun 30, 2011
Showing with 3 additions and 3 deletions.
  1. +2 −2 recordmodel-mysql.js
  2. +1 −1 recordmodel-sqlite.js
View
4 recordmodel-mysql.js
@@ -25,7 +25,7 @@ var get_schema = function(db, table, cb) {
*/
var query = function(db, query, args, cb) {
var args = typeof args == 'object' ? args : [];
- sys.puts("SQL: " + query)
+ //sys.puts("SQL: " + query)
db.query(query, args, function(err, rows, fields){
if(err) {
require('sys').puts("SQL ERROR: " + err);
@@ -118,7 +118,7 @@ var RecordSelector = function(q, args, model) {
*/
this.one = function(cb) {
self._get_ids(function(ids){
- if(typeof ids[it_ptr] == 'undefined') cb.call(self, false);
+ if(typeof ids[it_ptr] == 'undefined') return cb.call(self, false);
model.load(ids[it_ptr++], function(rec){
cb.call(self, rec);
});
View
2 recordmodel-sqlite.js
@@ -127,7 +127,7 @@ var RecordSelector = function(q, args, model) {
*/
this.one = function(cb) {
self._get_ids(function(ids){
- if(typeof ids[it_ptr] == 'undefined') cb.call(self, false);
+ if(typeof ids[it_ptr] == 'undefined') return cb.call(self, false);
model.load(ids[it_ptr++], function(rec){
cb.call(self, rec);
});

0 comments on commit 8cecdda

Please sign in to comment.