diff --git a/lib/Drivers/DML/sqlite.js b/lib/Drivers/DML/sqlite.js index 63b6a043..624e331a 100644 --- a/lib/Drivers/DML/sqlite.js +++ b/lib/Drivers/DML/sqlite.js @@ -215,12 +215,26 @@ Driver.prototype.remove = function (table, conditions, cb) { }; Driver.prototype.clear = function (table, cb) { - var query = "DELETE FROM " + this.query.escapeId(table); + var query = "DELETE FROM " + this.query.escapeId(table), + debug = this.opts.debug; - if (this.opts.debug) { + if (debug) { require("../../Debug").sql('sqlite', query); } - this.db.all(query, cb); + this.db.all(query, function (err) { + if (err) { + return cb(err); + } + var query = "DELETE FROM " + + this.query.escapeId("sqlite_sequence") + + " WHERE name=" + + this.query.escapeVal(table); + + if (debug) { + require("../../Debug").sql('sqlite', query); + } + this.db.all(query, cb); + }.bind(this)); }; Driver.prototype.valueToProperty = function (value, property) {