Browse files

Don't attempt to create tables again before resetting.

  • Loading branch information...
1 parent 42f1362 commit d36d08f5132ab2e7526e7df0d133d88838f3b5a3 @zefhemel zefhemel committed Aug 10, 2010
Showing with 17 additions and 10 deletions.
  1. +17 −10 persistence.js
View
27 persistence.js
@@ -251,17 +251,19 @@ persistence.get = function(arg1, arg2) {
* function to be called when synchronization has completed,
* takes started transaction as argument
*/
- persistence.schemaSync = function (tx, callback) {
+ persistence.schemaSync = function (tx, callback, emulate) {
var args = argspec.getArgs(arguments, [
{ name: "tx", optional: true, check: isTransaction, defaultValue: null },
- { name: "callback", optional: true, check: argspec.isCallback(), defaultValue: function(){} }
+ { name: "callback", optional: true, check: argspec.isCallback(), defaultValue: function(){} },
+ { name: "emulate", optional: true, check: argspec.hasType('boolean') }
]);
tx = args.tx;
callback = args.callback;
+ emulate = args.emulate;
if(!tx) {
var session = this;
- this.transaction(function(tx) { session.schemaSync(tx, callback); });
+ this.transaction(function(tx) { session.schemaSync(tx, callback, emulate); });
return;
}
var queries = [], meta, rowDef, otherMeta, tableName;
@@ -314,13 +316,18 @@ persistence.get = function(arg1, arg2) {
null ]);
}
}
- var fns = persistence.schemaSyncHooks;
- for(var i = 0; i < fns.length; i++) {
- fns[i](tx);
+ if(emulate) {
+ // Done
+ callback(tx);
+ } else {
+ var fns = persistence.schemaSyncHooks;
+ for(var i = 0; i < fns.length; i++) {
+ fns[i](tx);
+ }
+ executeQueriesSeq(tx, queries, function() {
+ callback(tx);
+ });
}
- executeQueriesSeq(tx, queries, function() {
- callback(tx);
- });
};
/**
@@ -480,7 +487,7 @@ persistence.get = function(arg1, arg2) {
session.clean();
persistence.generatedTables = {};
- });
+ }, true);
}
/**

0 comments on commit d36d08f

Please sign in to comment.