diff --git a/History.md b/History.md index c068a197..852a4531 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,10 @@ +#0.7.0 + +* Fix for issue [#121](https://github.com/C2FO/patio/issues/121) added the table name to the error thrown. +* Merged [#120](https://github.com/C2FO/patio/pull/120) this allows tables registered with DB to be looked up properly. + * This will break any `getModel` call where a table with the same name is added twice. +* Added documentation about running tests. + #0.6.1 * Added details for logging if the err.detail exists. diff --git a/README.md b/README.md index 5ab64017..e0592ee3 100755 --- a/README.md +++ b/README.md @@ -12,6 +12,26 @@ If you want to use the patio executable for migrations `npm install -g patio` +###Running Tests + +To run the tests + +``` +make test +``` + +To run just the postgres tests + +``` +make test-pg +``` + +To run just the mysql tests + +``` +make test-mysql +``` + ###Why Use Patio? Patio is different because it allows the developers to choose the level of abtraction they are comfortable with. diff --git a/docs-md/coverage.html b/docs-md/coverage.html index 8835c382..b4db6f30 100644 --- a/docs-md/coverage.html +++ b/docs-md/coverage.html @@ -256,10 +256,10 @@
- Coverage88.70 - SLOC22488 + Coverage88.72 + SLOC22485 LOC5540 - Missed626 + Missed625
@@ -954,7 +954,7 @@
  • 3 try {
  • 3 this.connection.setMaxListeners(0);
  • 3 var fields = [];
  • -
  • 3 query = new QueryStream(query);
  • +
  • 3 query = new QueryStream(query, null, {batchSize: 1, highWaterMark: 1});
  • 3 ret = this.connection.query(query);
  • 3 var orig = ret.handleRowDescription;
  • 3 ret.handleRowDescription = function (msg) {
  • @@ -3492,7 +3492,7 @@
  • * different databases.
  • */
  • getModel: function (name, db) {
  • -
  • 77 return model.getModel(name, db);
  • +
  • 79 return model.getModel(name, db);
  • },
  • /**
  • @@ -3763,7 +3763,7 @@
  • * @default []
  • */
  • DATABASES: function () {
  • -
  • 641 return Database.DATABASES;
  • +
  • 645 return Database.DATABASES;
  • },
  • /**
  • * Returns the default database. This is the first database created using {@link patio#connect}.
  • @@ -3772,7 +3772,7 @@
  • * @default null
  • */
  • defaultDatabase: function () {
  • -
  • 342 return this.DATABASES.length ? this.DATABASES[0] : null;
  • +
  • 344 return this.DATABASES.length ? this.DATABASES[0] : null;
  • },
  • /**@ignore*/
  • Database: function () {
  • @@ -4839,13 +4839,13 @@
  • * @return the typecasted value.
  • * */
  • typecastValue: function (columnType, value) {
  • -
  • 30708 if (isNull(value) || isUndefined(value)) {
  • +
  • 30709 if (isNull(value) || isUndefined(value)) {
  • 6472 return null;
  • }
  • -
  • 24236 var meth = "__typecastValue" + columnType.charAt(0).toUpperCase() + columnType.substr(1).toLowerCase();
  • -
  • 24236 try {
  • -
  • 24236 if (isFunction(this[meth])) {
  • -
  • 24236 return this[meth](value);
  • +
  • 24237 var meth = "__typecastValue" + columnType.charAt(0).toUpperCase() + columnType.substr(1).toLowerCase();
  • +
  • 24237 try {
  • +
  • 24237 if (isFunction(this[meth])) {
  • +
  • 24237 return this[meth](value);
  • } else {
  • 0 return value;
  • }
  • @@ -5020,7 +5020,7 @@
  • // Typecast the value to a String
  • __typecastValueString: function (value) {
  • -
  • 17339 return "" + value;
  • +
  • 17340 return "" + value;
  • }
  • },
  • @@ -6829,11 +6829,11 @@
  • * @property {Boolean} hasSelectSource true if this dataset already has a select sources.
  • */
  • constructor:function (db, opts) {
  • -
  • 27044 this._super(arguments);
  • -
  • 27044 this.db = db;
  • -
  • 27044 this.__opts = {};
  • -
  • 27044 this.__rowCb = null;
  • -
  • 27044 if (db) {
  • +
  • 27015 this._super(arguments);
  • +
  • 27015 this.db = db;
  • +
  • 27015 this.__opts = {};
  • +
  • 27015 this.__rowCb = null;
  • +
  • 27015 if (db) {
  • 13649 this.__quoteIdentifiers = db.quoteIdentifiers;
  • 13649 this.__identifierInputMethod = db.identifierInputMethod;
  • 13649 this.__identifierOutputMethod = db.identifierOutputMethod;
  • @@ -6931,20 +6931,20 @@
  • * </ul>
  • */
  • _splitString:function (s) {
  • -
  • 13053 var ret, m;
  • -
  • 13053 if ((m = s.match(this._static.COLUMN_REF_RE1)) !== null) {
  • +
  • 13063 var ret, m;
  • +
  • 13063 if ((m = s.match(this._static.COLUMN_REF_RE1)) !== null) {
  • 175 ret = m.slice(1);
  • }
  • -
  • 12878 else if ((m = s.match(this._static.COLUMN_REF_RE2)) !== null) {
  • +
  • 12888 else if ((m = s.match(this._static.COLUMN_REF_RE2)) !== null) {
  • 24 ret = [null, m[1], m[2]];
  • }
  • -
  • 12854 else if ((m = s.match(this._static.COLUMN_REF_RE3)) !== null) {
  • +
  • 12864 else if ((m = s.match(this._static.COLUMN_REF_RE3)) !== null) {
  • 2178 ret = [m[1], m[2], null];
  • }
  • else {
  • -
  • 10676 ret = [null, s, null];
  • +
  • 10686 ret = [null, s, null];
  • }
  • -
  • 13053 return ret;
  • +
  • 13063 return ret;
  • },
  • /**
  • @@ -6965,19 +6965,19 @@
  • },
  • firstSourceAlias:function () {
  • -
  • 486 var source = this.__opts.from;
  • -
  • 486 if (isUndefinedOrNull(source) || !source.length) {
  • +
  • 488 var source = this.__opts.from;
  • +
  • 488 if (isUndefinedOrNull(source) || !source.length) {
  • 2 throw new DatasetError("No source specified for the query");
  • }
  • -
  • 484 source = source[0];
  • -
  • 484 if (isInstanceOf(source, AliasedExpression)) {
  • +
  • 486 source = source[0];
  • +
  • 486 if (isInstanceOf(source, AliasedExpression)) {
  • 20 return source.alias;
  • -
  • 464 } else if (isString(source)) {
  • +
  • 466 } else if (isString(source)) {
  • 0 var parts = this._splitString(source);
  • 0 var alias = parts[2];
  • 0 return alias ? alias : source;
  • } else {
  • -
  • 464 return source;
  • +
  • 466 return source;
  • }
  • },
  • @@ -7055,10 +7055,10 @@
    - Coverage87.39 - SLOC1122 - LOC333 - Missed42 + Coverage87.65 + SLOC1118 + LOC332 + Missed41
    @@ -7095,11 +7095,7 @@
  • 1var MODELS = new HashTable();
  • 1var applyColumnTransformMethod = function (val, meth) {
  • -
  • 912 return !isUndefinedOrNull(meth) ? isFunction(val[meth]) ? val[meth] : isFunction(comb[meth]) ? comb[meth](val) : val : val;
  • -
  • };
  • -
  • -
  • 1var checkAndTransformName = function (name) {
  • -
  • 163 return isString(name) ? applyColumnTransformMethod(name, Model.camelize === true ? "camelize" : Model.underscore === true ? "underscore" : null) : name;
  • +
  • 757 return !isUndefinedOrNull(meth) ? isFunction(val[meth]) ? val[meth] : isFunction(comb[meth]) ? comb[meth](val) : val : val;
  • };
  • 1var Model = define([QueryPlugin, Middleware], {
  • @@ -7254,24 +7250,24 @@
  • * @borrows patio.Dataset#leftJoin as leftJoin
  • * */
  • constructor: function (options, fromDb) {
  • -
  • 2788 if (this.synced) {
  • -
  • 2788 this.__emitter = new EventEmitter();
  • -
  • 2788 this._super(arguments);
  • -
  • 2788 this.patio = patio || require("./index");
  • -
  • 2788 fromDb = isBoolean(fromDb) ? fromDb : false;
  • -
  • 2788 this.__changed = {};
  • -
  • 2788 this.__values = {};
  • -
  • 2788 if (fromDb) {
  • -
  • 1534 this._hook("pre", "load");
  • -
  • 1534 this.__isNew = false;
  • -
  • 1534 this.__setFromDb(options, true);
  • -
  • 1534 if (this._static.emitOnLoad) {
  • -
  • 1534 this.emit("load", this);
  • -
  • 1534 this._static.emit("load", this);
  • +
  • 2795 if (this.synced) {
  • +
  • 2795 this.__emitter = new EventEmitter();
  • +
  • 2795 this._super(arguments);
  • +
  • 2795 this.patio = patio || require("./index");
  • +
  • 2795 fromDb = isBoolean(fromDb) ? fromDb : false;
  • +
  • 2795 this.__changed = {};
  • +
  • 2795 this.__values = {};
  • +
  • 2795 if (fromDb) {
  • +
  • 1535 this._hook("pre", "load");
  • +
  • 1535 this.__isNew = false;
  • +
  • 1535 this.__setFromDb(options, true);
  • +
  • 1535 if (this._static.emitOnLoad) {
  • +
  • 1535 this.emit("load", this);
  • +
  • 1535 this._static.emit("load", this);
  • }
  • } else {
  • -
  • 1254 this.__isNew = true;
  • -
  • 1254 this.__set(options);
  • +
  • 1260 this.__isNew = true;
  • +
  • 1260 this.__set(options);
  • }
  • } else {
  • 0 throw new ModelError("Model " + this.tableName + " has not been synced");
  • @@ -7279,31 +7275,31 @@
  • },
  • __set: function (values, ignore) {
  • -
  • 1378 values = values || {};
  • -
  • 1378 this.__ignore = ignore === true;
  • -
  • 1378 Object.keys(values).forEach(function (attribute) {
  • +
  • 1384 values = values || {};
  • +
  • 1384 this.__ignore = ignore === true;
  • +
  • 1384 Object.keys(values).forEach(function (attribute) {
  • 6011 var value = values[attribute];
  • //check if the column is a constrained value and is allowed to be set
  • 6011 !ignore && this._checkIfColumnIsConstrained(attribute);
  • 6011 this[attribute] = value;
  • }, this);
  • -
  • 1378 this.__ignore = false;
  • +
  • 1384 this.__ignore = false;
  • },
  • __setFromDb: function (values, ignore) {
  • -
  • 2718 values = values || {};
  • -
  • 2718 this.__ignore = ignore === true;
  • -
  • 2718 var schema = this.schema;
  • -
  • 2718 Object.keys(values).forEach(function (column) {
  • -
  • 23831 var value = values[column];
  • +
  • 2719 values = values || {};
  • +
  • 2719 this.__ignore = ignore === true;
  • +
  • 2719 var schema = this.schema;
  • +
  • 2719 Object.keys(values).forEach(function (column) {
  • +
  • 23833 var value = values[column];
  • // Typecast value retrieved from db
  • -
  • 23831 if (schema.hasOwnProperty(column)) {
  • -
  • 23830 this.__values[column] = this._typeCastValue(column, value, ignore);
  • +
  • 23833 if (schema.hasOwnProperty(column)) {
  • +
  • 23831 this.__values[column] = this._typeCastValue(column, value, ignore);
  • } else {
  • -
  • 1 this[column] = value;
  • +
  • 2 this[column] = value;
  • }
  • }, this);
  • -
  • 2718 this.__ignore = false;
  • +
  • 2719 this.__ignore = false;
  • },
  • @@ -7369,8 +7365,8 @@
  • },
  • _setColumnValue: function (name, val) {
  • -
  • 6851 var ignore = this.__ignore;
  • -
  • 6851 val = this._typeCastValue(name, val, ignore);
  • +
  • 6852 var ignore = this.__ignore;
  • +
  • 6852 val = this._typeCastValue(name, val, ignore);
  • 6851 var setterFunc = this["_set" + name.charAt(0).toUpperCase() + name.substr(1)];
  • 6851 var columnValue = isFunction(setterFunc) ? setterFunc.call(this, val, ignore) : val;
  • 6851 this._addColumnToIsChanged(name, columnValue);
  • @@ -7385,25 +7381,25 @@
  • //typecast_value method, so database adapters can override/augment the handling
  • //for database specific column types.
  • _typeCastValue: function (column, value, fromDatabase) {
  • -
  • 30681 var colSchema, clazz = this._static;
  • -
  • 30681 if (((fromDatabase && clazz.typecastOnLoad) || (!fromDatabase && clazz.typecastOnAssignment)) && !isUndefinedOrNull(this.schema) && !isUndefinedOrNull((colSchema = this.schema[column]))) {
  • -
  • 30681 var type = colSchema.type;
  • -
  • 30681 if (value === "" && clazz.typecastEmptyStringToNull === true && !isUndefinedOrNull(type) && ["string", "blob"].indexOf(type) === -1) {
  • +
  • 30683 var colSchema, clazz = this._static;
  • +
  • 30683 if (((fromDatabase && clazz.typecastOnLoad) || (!fromDatabase && clazz.typecastOnAssignment)) && !isUndefinedOrNull(this.schema) && !isUndefinedOrNull((colSchema = this.schema[column]))) {
  • +
  • 30683 var type = colSchema.type;
  • +
  • 30683 if (value === "" && clazz.typecastEmptyStringToNull === true && !isUndefinedOrNull(type) && ["string", "blob"].indexOf(type) === -1) {
  • 3 value = null;
  • }
  • -
  • 30681 var raiseOnError = clazz.raiseOnTypecastError;
  • -
  • 30681 if (raiseOnError === true && isUndefinedOrNull(value) && colSchema.allowNull === false) {
  • -
  • 0 throw new ModelError("null is not allowed for the " + column + " column.");
  • +
  • 30683 var raiseOnError = clazz.raiseOnTypecastError;
  • +
  • 30683 if (raiseOnError === true && isUndefinedOrNull(value) && colSchema.allowNull === false) {
  • +
  • 1 throw new ModelError("null is not allowed for the " + column + " column on model " + clazz.tableName);
  • }
  • -
  • 30681 try {
  • -
  • 30681 value = clazz.db.typecastValue(type, value);
  • +
  • 30682 try {
  • +
  • 30682 value = clazz.db.typecastValue(type, value);
  • } catch (e) {
  • 0 if (raiseOnError === true) {
  • 0 throw e;
  • }
  • }
  • }
  • -
  • 30681 return value;
  • +
  • 30682 return value;
  • },
  • /**
  • @@ -7475,8 +7471,8 @@
  • 0 return emitter.listeners.apply(emitter, arguments);
  • },
  • emit: function () {
  • -
  • 9983 var emitter = this.__emitter;
  • -
  • 9983 return emitter.emit.apply(emitter, arguments);
  • +
  • 9984 var emitter = this.__emitter;
  • +
  • 9984 return emitter.emit.apply(emitter, arguments);
  • },
  • @@ -7534,7 +7530,7 @@
  • },
  • schema: function () {
  • -
  • 70091 return this._static.schema;
  • +
  • 70096 return this._static.schema;
  • },
  • columns: function () {
  • @@ -7542,7 +7538,7 @@
  • },
  • synced: function () {
  • -
  • 11510 return this._static.synced;
  • +
  • 11517 return this._static.synced;
  • }
  • }
  • @@ -7693,10 +7689,10 @@
  • 3 return when(supers.map(function (sup) {
  • 3 return sup.sync();
  • })).chain(function () {
  • -
  • 3 self.synced = true;
  • -
  • 3 supers.forEach(self.inherits, self);
  • -
  • 3 return self;
  • -
  • });
  • +
  • 3 self.synced = true;
  • +
  • 3 supers.forEach(self.inherits, self);
  • +
  • 3 return self;
  • +
  • });
  • } else {
  • 83 self.synced = true;
  • 83 return self;
  • @@ -7769,7 +7765,7 @@
  • 2455 var retVal = null, errored = false, self = this;
  • 2455 return this.sync().chain(function () {
  • 2455 if (self.useTransaction(opts)) {
  • -
  • 2455 return self.db.transaction(opts,function () {
  • +
  • 2455 return self.db.transaction(opts, function () {
  • 2455 return when(cb()).chain(function (val) {
  • 2410 retVal = val;
  • }, function (err) {
  • @@ -7777,18 +7773,18 @@
  • 45 errored = true;
  • });
  • }).chain(function () {
  • -
  • 2455 if (errored) {
  • -
  • 45 throw retVal;
  • -
  • } else {
  • -
  • 2410 return retVal;
  • -
  • }
  • -
  • }, function (err) {
  • -
  • 45 if (errored) {
  • -
  • 45 throw retVal;
  • -
  • } else {
  • -
  • 0 throw err;
  • -
  • }
  • -
  • });
  • +
  • 2455 if (errored) {
  • +
  • 45 throw retVal;
  • +
  • } else {
  • +
  • 2410 return retVal;
  • +
  • }
  • +
  • }, function (err) {
  • +
  • 45 if (errored) {
  • +
  • 45 throw retVal;
  • +
  • } else {
  • +
  • 0 throw err;
  • +
  • }
  • +
  • });
  • } else {
  • 0 return when(cb());
  • }
  • @@ -7856,7 +7852,7 @@
  • _defineColumnSetter: function (name) {
  • /*Adds a setter to an object*/
  • 757 this.prototype.__defineSetter__(name, function (val) {
  • -
  • 6851 this._setColumnValue(name, val);
  • +
  • 6852 this._setColumnValue(name, val);
  • });
  • },
  • @@ -7916,7 +7912,7 @@
  • * @type {Boolean}
  • */
  • camelize: function (camelize) {
  • -
  • 156 return this.__camelize;
  • +
  • 1 return this.__camelize;
  • },
  • @@ -7929,7 +7925,7 @@
  • * @type {Boolean}
  • */
  • underscore: function (underscore) {
  • -
  • 3 return this.__underscore;
  • +
  • 1 return this.__underscore;
  • },
  • @@ -7942,7 +7938,7 @@
  • * @type String
  • */
  • tableName: function () {
  • -
  • 4645 return this.__tableName;
  • +
  • 4646 return this.__tableName;
  • },
  • /**
  • @@ -7952,14 +7948,14 @@
  • * @type patio.Database
  • */
  • db: function () {
  • -
  • 33372 var db = this.__db;
  • -
  • 33372 if (!db) {
  • +
  • 33373 var db = this.__db;
  • +
  • 33373 if (!db) {
  • 45 db = this.__db = patio.defaultDatabase;
  • }
  • -
  • 33372 if (!db) {
  • +
  • 33373 if (!db) {
  • 0 throw new ModelError("patio has not been connected to a database");
  • }
  • -
  • 33372 return db;
  • +
  • 33373 return db;
  • },
  • /**
  • @@ -8008,8 +8004,8 @@
  • * @type Object
  • */
  • schema: function () {
  • -
  • 70095 if (this.synced) {
  • -
  • 70095 return this.__schema;
  • +
  • 70100 if (this.synced) {
  • +
  • 70100 return this.__schema;
  • } else {
  • 0 throw new ModelError("Model has not been synced yet");
  • }
  • @@ -8075,23 +8071,24 @@
  • }
  • }
  • +
  • 1var allModels = [];
  • /**@ignore*/
  • 1exports.create = function (name, supers, modelOptions) {
  • 86 if (!patio) {
  • 1 (patio = require("./index"));
  • 1 patio.on("disconnect", function () {
  • +
  • 36 allModels.length = 0;
  • 36 MODELS.clear();
  • });
  • }
  • -
  • 86 var db, ds, tableName;
  • -
  • 86 var key, modelKey;
  • +
  • 86 var db, ds, tableName, modelKey;
  • 86 if (isString(name)) {
  • 80 tableName = name;
  • -
  • 80 key = db = patio.defaultDatabase || "default";
  • +
  • 80 db = patio.defaultDatabase || "default";
  • 6 } else if (isInstanceOf(name, patio.Dataset)) {
  • 6 ds = name;
  • -
  • 6 tableName = ds.firstSourceAlias;
  • -
  • 6 key = db = ds.db;
  • +
  • 6 tableName = ds.firstSourceAlias.toString();
  • +
  • 6 db = ds.db;
  • }
  • 86 var hasSuper = false;
  • 86 if (isHash(supers) || isUndefinedOrNull(supers)) {
  • @@ -8106,7 +8103,7 @@
  • }
  • 86 var model;
  • -
  • 86 checkAndAddDBToTable(key, MODELS);
  • +
  • 86 checkAndAddDBToTable(db, MODELS);
  • 86 var DEFAULT_PROTO = {instance: {}, "static": {}};
  • 86 modelOptions = merge(DEFAULT_PROTO, modelOptions || {});
  • @@ -8127,44 +8124,43 @@
  • }
  • }
  • });
  • -
  • 86 if (!(MODELS.get(key).contains(checkAndTransformName(name)))) {
  • -
  • 53 MODELS.get(key).set(name, model);
  • +
  • 86 allModels.push(model);
  • +
  • 86 if (!(MODELS.get(db).contains(tableName))) {
  • +
  • 51 MODELS.get(db).set(tableName, model);
  • }
  • 86 return model;
  • };
  • 1exports.syncModels = function (cb) {
  • -
  • 31 return asyncArray(MODELS.entrySet).map(function (entry) {
  • -
  • 30 var value = entry.value;
  • -
  • 30 return asyncArray(value.entrySet).map(function (m) {
  • -
  • 53 return m.value.sync();
  • -
  • }, 1);
  • +
  • 31 return asyncArray(allModels).forEach(function (model) {
  • +
  • 53 return model.sync();
  • }, 1).classic(cb).promise();
  • };
  • 1var checkAndGetModel = function (db, name) {
  • -
  • 152 var ret;
  • -
  • 152 if (MODELS.contains(db)) {
  • -
  • 77 ret = MODELS.get(db).get(checkAndTransformName(name));
  • +
  • 154 var ret;
  • +
  • 154 if (MODELS.contains(db)) {
  • +
  • 79 ret = MODELS.get(db).get(name);
  • }
  • -
  • 152 return ret;
  • +
  • 154 return ret;
  • };
  • 1exports.getModel = function (name, db) {
  • -
  • 80 var ret = null;
  • -
  • 80 if (isDefined(name)) {
  • -
  • 80 !patio && (patio = require("./index"));
  • -
  • 80 if (isFunction(name)) {
  • +
  • 82 var ret = null;
  • +
  • 82 if (isDefined(name)) {
  • +
  • 82 !patio && (patio = require("./index"));
  • +
  • 82 if (isFunction(name)) {
  • 3 ret = name;
  • } else {
  • -
  • 77 if (!db && isInstanceOf(name, patio.Dataset)) {
  • +
  • 79 if (!db && isInstanceOf(name, patio.Dataset)) {
  • 2 db = name.db;
  • +
  • 2 name = name.firstSourceAlias.toString();
  • }
  • -
  • 77 var defaultDb = patio.defaultDatabase;
  • -
  • 77 if (db) {
  • -
  • 51 ret = checkAndGetModel(db, name);
  • -
  • 51 if (!ret && db === defaultDb) {
  • +
  • 79 var defaultDb = patio.defaultDatabase;
  • +
  • 79 if (db) {
  • +
  • 53 ret = checkAndGetModel(db, name);
  • +
  • 53 if (!ret && db === defaultDb) {
  • 49 ret = checkAndGetModel("default", name);
  • }
  • } else {
  • @@ -8178,10 +8174,10 @@
  • } else {
  • 0 ret = name;
  • }
  • -
  • 80 if (isUndefinedOrNull(ret)) {
  • +
  • 82 if (isUndefinedOrNull(ret)) {
  • 0 throw new ModelError("Model " + name + " has not been registered with patio");
  • }
  • -
  • 80 return ret;
  • +
  • 82 return ret;
  • };
  • @@ -9514,18 +9510,18 @@
  • 1var virtualRow = function (name) {
  • -
  • 1249 var DOUBLE_UNDERSCORE = '__';
  • +
  • 1262 var DOUBLE_UNDERSCORE = '__';
  • -
  • 1249 var parts = name.split(DOUBLE_UNDERSCORE);
  • -
  • 1249 var table = parts[0], column = parts[1];
  • -
  • 1249 var ident = column ? QualifiedIdentifier.fromArgs([table, column]) : Identifier.fromArgs([name]);
  • -
  • 1249 var prox = methodMissing(ident, function (m) {
  • +
  • 1262 var parts = name.split(DOUBLE_UNDERSCORE);
  • +
  • 1262 var table = parts[0], column = parts[1];
  • +
  • 1262 var ident = column ? QualifiedIdentifier.fromArgs([table, column]) : Identifier.fromArgs([name]);
  • +
  • 1262 var prox = methodMissing(ident, function (m) {
  • 3 return function () {
  • 3 var args = argsToArray(arguments);
  • 3 return SQLFunction.fromArgs([m, name].concat(args));
  • };
  • }, column ? QualifiedIdentifier : Identifier);
  • -
  • 1249 var ret = createFunctionWrapper(prox, function (m) {
  • +
  • 1262 var ret = createFunctionWrapper(prox, function (m) {
  • 663 var args = argsToArray(arguments);
  • 663 if (args.length) {
  • 657 return SQLFunction.fromArgs([name].concat(args));
  • @@ -9535,8 +9531,8 @@
  • }, function () {
  • 0 return SQLFunction.fromArgs(arguments);
  • });
  • -
  • 1249 ret["__proto__"] = ident;
  • -
  • 1249 return ret;
  • +
  • 1262 ret["__proto__"] = ident;
  • +
  • 1262 return ret;
  • };
  • 1var DATE_METHODS = ["getDate", "getDay", "getFullYear", "getHours", "getMilliseconds", "getMinutes", "getMonth", "getSeconds",
  • @@ -10015,7 +10011,7 @@
  • });
  • 1exports.sql = methodMissing(sql, function (name) {
  • -
  • 1249 return virtualRow(name);
  • +
  • 1262 return virtualRow(name);
  • });
  • 1var OPERTATOR_INVERSIONS = {
  • @@ -10827,13 +10823,13 @@
  • * @return {patio.sql.Expression} an expression.
  • */
  • fromArgs: function (args) {
  • -
  • 2648 var ret, Self = this;
  • -
  • 2648 try {
  • -
  • 2648 ret = new Self();
  • +
  • 2661 var ret, Self = this;
  • +
  • 2661 try {
  • +
  • 2661 ret = new Self();
  • } catch (ignore) {
  • }
  • -
  • 2648 this.apply(ret, args);
  • -
  • 2648 return ret;
  • +
  • 2661 this.apply(ret, args);
  • +
  • 2661 return ret;
  • },
  • /**
  • @@ -11636,7 +11632,7 @@
  • * @property {String} value <b>READ ONLY</b> the column or table this identifier represents.
  • */
  • constructor: function (value) {
  • -
  • 15953 this.__value = value;
  • +
  • 15979 this.__value = value;
  • },
  • /**
  • @@ -11648,15 +11644,15 @@
  • * @return String the SQL version of the {@link patio.sql.Identifier}.
  • */
  • toString: function (ds) {
  • -
  • 19892 !Dataset && (Dataset = require("./dataset"));
  • -
  • 19892 ds = ds || new Dataset();
  • -
  • 19892 return ds.quoteIdentifier(this);
  • +
  • 19863 !Dataset && (Dataset = require("./dataset"));
  • +
  • 19863 ds = ds || new Dataset();
  • +
  • 19863 return ds.quoteIdentifier(this);
  • },
  • /**@ignore*/
  • getters: {
  • value: function () {
  • -
  • 23097 return this.__value;
  • +
  • 23058 return this.__value;
  • }
  • }
  • }
  • @@ -12965,10 +12961,10 @@
  • constructor: function () {
  • //We initialize these here because otherwise
  • //the will be blank because of recursive dependencies.
  • -
  • 27044 !patio && (patio = require("../index"));
  • -
  • 27044 !Dataset && (Dataset = patio.Dataset);
  • -
  • 27044 this.outputIdentifier = hitch(this, this.outputIdentifier);
  • -
  • 27044 this._super(arguments);
  • +
  • 27015 !patio && (patio = require("../index"));
  • +
  • 27015 !Dataset && (Dataset = patio.Dataset);
  • +
  • 27015 this.outputIdentifier = hitch(this, this.outputIdentifier);
  • +
  • 27015 this._super(arguments);
  • },
  • /**
  • @@ -13776,18 +13772,18 @@
  • * quote the name with {@link patio.dataset._Sql#_quotedIdentifier}.
  • */
  • quoteIdentifier: function (name) {
  • -
  • 31682 if (isInstanceOf(name, LiteralString)) {
  • +
  • 31653 if (isInstanceOf(name, LiteralString)) {
  • 93 return name;
  • } else {
  • -
  • 31589 if (isInstanceOf(name, Identifier)) {
  • -
  • 20224 name = name.value;
  • +
  • 31560 if (isInstanceOf(name, Identifier)) {
  • +
  • 20195 name = name.value;
  • }
  • -
  • 31589 name = this.inputIdentifier(name);
  • -
  • 31589 if (this.quoteIdentifiers) {
  • +
  • 31560 name = this.inputIdentifier(name);
  • +
  • 31560 if (this.quoteIdentifiers) {
  • 25073 name = this._quotedIdentifier(name)
  • }
  • }
  • -
  • 31589 return name;
  • +
  • 31560 return name;
  • },
  • /**
  • @@ -13797,9 +13793,9 @@
  • * identifierOutputMethod.
  • */
  • inputIdentifier: function (v) {
  • -
  • 31761 var i = this.__identifierInputMethod;
  • -
  • 31761 v = v.toString(this);
  • -
  • 31761 return !isUndefinedOrNull(i) ?
  • +
  • 31732 var i = this.__identifierInputMethod;
  • +
  • 31732 v = v.toString(this);
  • +
  • 31732 return !isUndefinedOrNull(i) ?
  • isFunction(v[i]) ?
  • v[i]() :
  • isFunction(comb[i]) ?
  • @@ -13847,13 +13843,13 @@
  • schemaAndTable: function (tableName) {
  • 2231 var sch = this.db ? this.db.defaultSchema || null : null;
  • 2231 if (isString(tableName)) {
  • -
  • 792 var parts = this._splitString(tableName);
  • -
  • 792 var s = parts[0], table = parts[1];
  • -
  • 792 return [s || sch, table];
  • -
  • 1439 } else if (isInstanceOf(tableName, QualifiedIdentifier)) {
  • +
  • 802 var parts = this._splitString(tableName);
  • +
  • 802 var s = parts[0], table = parts[1];
  • +
  • 802 return [s || sch, table];
  • +
  • 1429 } else if (isInstanceOf(tableName, QualifiedIdentifier)) {
  • 3 return [tableName.table, tableName.column]
  • -
  • 1436 } else if (isInstanceOf(tableName, Identifier)) {
  • -
  • 1436 return [null, tableName.value];
  • +
  • 1426 } else if (isInstanceOf(tableName, Identifier)) {
  • +
  • 1426 return [null, tableName.value];
  • } else {
  • 0 throw new QueryError("table should be a QualifiedIdentifier, Identifier, or String");
  • }
  • @@ -16009,7 +16005,7 @@
  • * @param {String} message the message to show.
  • */
  • 1patio.ModelError = function(message) {
  • -
  • 2 return new Error("Model error : " + message);
  • +
  • 3 return new Error("Model error : " + message);
  • };
  • /**
  • @@ -16091,10 +16087,10 @@
  • /**@ignore*/
  • constructor: function () {
  • -
  • 27044 if (!Dataset) {
  • +
  • 27015 if (!Dataset) {
  • 1 Dataset = require("../index").Dataset;
  • }
  • -
  • 27044 this._super(arguments);
  • +
  • 27015 this._super(arguments);
  • },
  • @@ -17398,10 +17394,10 @@
  • *
  • */
  • constructor: function () {
  • -
  • 2788 if (comb.isUndefinedOrNull(this.__associations)) {
  • -
  • 2682 this.__associations = {};
  • +
  • 2795 if (comb.isUndefinedOrNull(this.__associations)) {
  • +
  • 2686 this.__associations = {};
  • }
  • -
  • 2788 this._super(arguments);
  • +
  • 2795 this._super(arguments);
  • },
  • reload: function () {
  • @@ -18419,17 +18415,17 @@
  • * @ignore
  • */
  • constructor: function () {
  • -
  • 27044 !Dataset && (Dataset = require("../index").Dataset);
  • -
  • 27044 this._super(arguments);
  • -
  • 27044 this._static.CONDITIONED_JOIN_TYPES.forEach(function (type) {
  • -
  • 189308 if (!this[type + "Join"]) {
  • -
  • 189308 this[type + "Join"] = hitch(this, conditionedJoin, type);
  • +
  • 27015 !Dataset && (Dataset = require("../index").Dataset);
  • +
  • 27015 this._super(arguments);
  • +
  • 27015 this._static.CONDITIONED_JOIN_TYPES.forEach(function (type) {
  • +
  • 189105 if (!this[type + "Join"]) {
  • +
  • 189105 this[type + "Join"] = hitch(this, conditionedJoin, type);
  • }
  • }, this);
  • -
  • 27044 this._static.UNCONDITIONED_JOIN_TYPES.forEach(function (type) {
  • -
  • 135220 if (!this[type + "Join"]) {
  • -
  • 135220 this[type + "Join"] = hitch(this, unConditionJoin, type);
  • +
  • 27015 this._static.UNCONDITIONED_JOIN_TYPES.forEach(function (type) {
  • +
  • 135075 if (!this[type + "Join"]) {
  • +
  • 135075 this[type + "Join"] = hitch(this, unConditionJoin, type);
  • }
  • }, this);
  • @@ -21096,8 +21092,8 @@
  • * @ignore
  • */
  • constructor: function () {
  • -
  • 27044 !Dataset && (Dataset = require("../index").Dataset);
  • -
  • 27044 this._super(arguments);
  • +
  • 27015 !Dataset && (Dataset = require("../index").Dataset);
  • +
  • 27015 this._super(arguments);
  • },
  • /**
  • @@ -21818,8 +21814,8 @@
    Coverage100.00 - SLOC207 - LOC60 + SLOC208 + LOC61 Missed0
    @@ -21926,7 +21922,8 @@
  • 7041 self.logDebug("Duration: % 6dms; %s", new Date() - start, sql);
  • 7041 spreadArgs(ret.callback, arguments);
  • }, function (err) {
  • -
  • 72 err = new QueryError(format("%s: %s", err.message, sql));
  • +
  • 72 var details = err.detail;
  • +
  • 72 err = new QueryError(format("%s%s: %s", err.message, details ? " DETAIL('" + details + "')" : "", sql));
  • 72 self.logError(err);
  • 72 ret.errback(err);
  • }).addErrback(ret.errback);
  • @@ -22076,7 +22073,7 @@
  • // Whether this dataset quotes identifiers.
  • /**@ignore*/
  • quoteIdentifiers: function () {
  • -
  • 45458 return this.__quoteIdentifiers;
  • +
  • 45429 return this.__quoteIdentifiers;
  • },
  • // Whether this dataset will provide accurate number of rows matched for
  • diff --git a/docs/History.html b/docs/History.html index 1c92cb3c..2749bb4b 100644 --- a/docs/History.html +++ b/docs/History.html @@ -362,6 +362,15 @@ +

    0.7.0

    +

    0.6.1