diff --git a/index.js b/index.js index d078c192..671b709f 100644 --- a/index.js +++ b/index.js @@ -18,3 +18,4 @@ try { exports.version = require('../package').version; } } catch (e) {} + diff --git a/lib/adapters/mongoose.js b/lib/adapters/mongoose.js index 19f642f9..4c0ab333 100644 --- a/lib/adapters/mongoose.js +++ b/lib/adapters/mongoose.js @@ -67,7 +67,9 @@ MongooseAdapter.prototype.getCached = function (model, id, cb) { cb(null, this.cache[model][id]); } else { this._models[model].findById(id, function (err, instance) { - if (err) return cb(err); + if (err) { + return cb(err); + } this.cache[model][id] = instance; cb(null, instance); }.bind(this)); @@ -83,7 +85,9 @@ MongooseAdapter.prototype.create = function (model, data, callback) { MongooseAdapter.prototype.save = function (model, data, callback) { this.getCached(model, data.id, function (err, inst) { - if (err) return callback(err); + if (err) { + return callback(err); + } merge(inst, data); inst.save(callback); }); @@ -92,7 +96,9 @@ MongooseAdapter.prototype.save = function (model, data, callback) { MongooseAdapter.prototype.exists = function (model, id, callback) { delete this.cache[model][id]; this.getCached(model, id, function (err, data) { - if (err) return callback(err); + if (err) { + return callback(err); + } callback(err, !!data); }); }; @@ -100,16 +106,23 @@ MongooseAdapter.prototype.exists = function (model, id, callback) { MongooseAdapter.prototype.find = function find(model, id, callback) { delete this.cache[model][id]; this.getCached(model, id, function (err, data) { - if (err) return callback(err); + if (err) { + return callback(err); + } callback(err, data ? data.toObject() : null); }); }; MongooseAdapter.prototype.destroy = function destroy(model, id, callback) { this.getCached(model, id, function (err, data) { - if (err) return callback(err); - if (data) data.remove(callback); - else callback(null); + if (err) { + return callback(err); + } + if (data) { + data.remove(callback); + } else { + callback(null); + } }); }; diff --git a/lib/adapters/postgres.js b/lib/adapters/postgres.js index e3f848c0..aff215c3 100644 --- a/lib/adapters/postgres.js +++ b/lib/adapters/postgres.js @@ -196,7 +196,7 @@ PG.prototype.fromDatabase = function (model, data) { }; PG.prototype.escapeName = function (name) { - return '"' + name + '"'; + return '"' + name.replace(/\./g, '"."') + '"'; }; PG.prototype.all = function all(model, filter, callback) { diff --git a/lib/hookable.js b/lib/hookable.js index 907fc2f9..bc5faa17 100644 --- a/lib/hookable.js +++ b/lib/hookable.js @@ -38,8 +38,11 @@ Hookable.prototype.trigger = function trigger(actionName, work, data) { } function next(done) { - if (afterHook) afterHook.call(inst, done); - else if (done) done.call(this); + if (afterHook) { + afterHook.call(inst, done); + } else if (done) { + done.call(this); + } } }; diff --git a/lib/validatable.js b/lib/validatable.js index 8a81bd9f..3600e6f4 100644 --- a/lib/validatable.js +++ b/lib/validatable.js @@ -257,7 +257,7 @@ function validateUniqueness(attr, conf, err, done) { this.constructor.all(cond, function (error, found) { if (found.length > 1) { err(); - } else if (found.length === 1 && found[0].id !== this.id) { + } else if (found.length === 1 && found[0].id != this.id) { err(); } done(); diff --git a/test/common_test.js b/test/common_test.js index 4a6c5685..b7285917 100644 --- a/test/common_test.js +++ b/test/common_test.js @@ -1,8 +1,8 @@ +require('./spec_helper').init(exports); + var Schema = require('../index').Schema; var Text = Schema.Text; -require('./spec_helper').init(exports); - var schemas = { // riak: {}, mysql: { diff --git a/test/spec_helper.js b/test/spec_helper.js index 5e02b7f0..4f199d21 100644 --- a/test/spec_helper.js +++ b/test/spec_helper.js @@ -1,3 +1,7 @@ +var semicov = require('semicov'); +semicov.init('lib'); +process.on('exit', semicov.report); + try { global.sinon = require('sinon'); } catch (e) {