Skip to content

Commit

Permalink
Fixes autoFetchLimit and cascadeRemove options not being used when se…
Browse files Browse the repository at this point in the history
…t to 0 or false (fixes #144)
  • Loading branch information
dresende committed May 3, 2013
1 parent 15e63eb commit 7983efd
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions lib/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ function Model(opts) {
conditions[opts.keys[i]] = ids[i];
}

if (!options.hasOwnProperty("autoFetchLimit")) {
options.autoFetchLimit = opts.autoFetchLimit;
}
if (!options.hasOwnProperty("cascadeRemove")) {
options.cascadeRemove = opts.cascadeRemove;
}

opts.driver.find(model_fields, opts.table, conditions, { limit: 1 }, function (err, data) {
if (err) {
return cb(err);
Expand All @@ -172,8 +179,8 @@ function Model(opts) {
return createInstance(data[0], {
autoSave : opts.autoSave,
autoFetch : (options.autoFetchLimit === 0 ? false : opts.autoFetch),
autoFetchLimit : options.autoFetchLimit || opts.autoFetchLimit,
cascadeRemove : options.cascadeRemove || opts.cascadeRemove
autoFetchLimit : options.autoFetchLimit,
cascadeRemove : options.cascadeRemove
}, cb);
}, function (instance) {
return cb(null, instance);
Expand Down Expand Up @@ -237,6 +244,12 @@ function Model(opts) {
if (!options.hasOwnProperty("cache")) {
options.cache = opts.cache;
}
if (!options.hasOwnProperty("autoFetchLimit")) {
options.autoFetchLimit = opts.autoFetchLimit;
}
if (!options.hasOwnProperty("cascadeRemove")) {
options.cascadeRemove = opts.cascadeRemove;
}

if (order) {
order = Utilities.standardizeOrder(order);
Expand All @@ -261,8 +274,8 @@ function Model(opts) {
return createInstance(data, {
autoSave : opts.autoSave,
autoFetch : (options.autoFetchLimit === 0 ? false : (options.autoFetch || opts.autoFetch)),
autoFetchLimit : options.autoFetchLimit || opts.autoFetchLimit,
cascadeRemove : options.cascadeRemove || opts.cascadeRemove,
autoFetchLimit : options.autoFetchLimit,
cascadeRemove : options.cascadeRemove,
extra : options.extra,
extra_info : options.extra_info
}, cb);
Expand Down

0 comments on commit 7983efd

Please sign in to comment.