diff --git a/History.md b/History.md index 4ca1e267..9c748b20 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +#v0.2.15 + +* Updated patio migrate to use an exit code of `1` if the migration fails. [#92](https://github.com/C2FO/patio/issues/92) +* Fixed the use of hashes in `andGrouped*` methods. + # v0.2.14 * Converted uses of `.then` to `.chain` diff --git a/bin/patio b/bin/patio index 11873605..0993b86b 100755 --- a/bin/patio +++ b/bin/patio @@ -34,6 +34,7 @@ program.command("migrate") ["directory", "uri"].forEach(function (arg) { if (comb.isUndefined(program[arg])) { self.missingArgument(arg); + process.exit(1); } }); @@ -61,6 +62,7 @@ program.command("migrate") var disconnectError = function (err) { patio.logError(err); patio.disconnect(); + process.exit(1); }; var start = new Date(); diff --git a/docs-md/coverage.html b/docs-md/coverage.html index 827b7d68..5cbdc95d 100644 --- a/docs-md/coverage.html +++ b/docs-md/coverage.html @@ -256,10 +256,10 @@
- Coverage88.52 - SLOC22278 - LOC5391 - Missed619 + Coverage88.48 + SLOC22271 + LOC5384 + Missed620
@@ -992,8 +992,8 @@
  • * Checks all deferred connection requests.
  • */
  • __checkQueries: function () {
  • -
  • 2252 var fc = this.freeCount, def, defQueue = this.__deferredQueue;
  • -
  • 2252 while (fc-- >= 0 && defQueue.count) {
  • +
  • 2290 var fc = this.freeCount, def, defQueue = this.__deferredQueue;
  • +
  • 2290 while (fc-- >= 0 && defQueue.count) {
  • 0 def = defQueue.dequeue();
  • 0 var conn = this.getObject();
  • 0 if (conn) {
  • @@ -1013,23 +1013,23 @@
  • * @return {comb.Promise} A promise to called back with a connection.
  • */
  • getConnection: function () {
  • -
  • 2257 var ret = new Promise();
  • -
  • 2257 if (this.count > this.__maxObjects) {
  • +
  • 2295 var ret = new Promise();
  • +
  • 2295 if (this.count > this.__maxObjects) {
  • 0 this.__deferredQueue.enqueue(ret);
  • } else {
  • //todo override getObject to make async so creating a connetion can execute setup sql
  • -
  • 2257 var conn = this.getObject();
  • -
  • 2257 if (!conn) {
  • +
  • 2295 var conn = this.getObject();
  • +
  • 2295 if (!conn) {
  • //we need to deffer it
  • 0 this.__deferredQueue.enqueue(ret);
  • } else {
  • -
  • 2257 ret.callback(conn);
  • +
  • 2295 ret.callback(conn);
  • }
  • }
  • -
  • 2257 if (this.count > this.__maxObjects && !conn) {
  • +
  • 2295 if (this.count > this.__maxObjects && !conn) {
  • 0 ret.errback(new Error("Unexpected ConnectionPool error"));
  • }
  • -
  • 2257 return ret.promise();
  • +
  • 2295 return ret.promise();
  • },
  • /**
  • @@ -1040,13 +1040,13 @@
  • *
  • */
  • returnObject: function (obj) {
  • -
  • 2252 var self = this;
  • -
  • 2252 this.validate(obj).chain(function (valid) {
  • -
  • 2252 var index;
  • -
  • 2252 if (self.count <= self.__maxObjects && valid && (index = self.__inUseObjects.indexOf(obj)) > -1) {
  • -
  • 2252 self.__inUseObjects.splice(index, 1);
  • -
  • 2252 self.__freeObjects.enqueue(obj);
  • -
  • 2252 self.__checkQueries();
  • +
  • 2290 var self = this;
  • +
  • 2290 this.validate(obj).chain(function (valid) {
  • +
  • 2290 var index;
  • +
  • 2290 if (self.count <= self.__maxObjects && valid && (index = self.__inUseObjects.indexOf(obj)) > -1) {
  • +
  • 2290 self.__inUseObjects.splice(index, 1);
  • +
  • 2290 self.__freeObjects.enqueue(obj);
  • +
  • 2290 self.__checkQueries();
  • } else {
  • 0 self.removeObject(obj);
  • }
  • @@ -1070,7 +1070,7 @@
  • * @return {*} an adapter specific connection.
  • */
  • returnConnection: function (connection) {
  • -
  • 2252 this.returnObject(connection);
  • +
  • 2290 this.returnObject(connection);
  • },
  • createObject: function () {
  • @@ -1105,12 +1105,12 @@
  • * @return {comb.Promise} called back with a valid or invalid state.
  • */
  • validate: function (conn) {
  • -
  • 2252 if (!this.__validateConnectionCB) {
  • +
  • 2290 if (!this.__validateConnectionCB) {
  • 0 var ret = new Promise();
  • 0 ret.callback(true);
  • 0 return ret;
  • } else {
  • -
  • 2252 return this.__validateConnectionCB();
  • +
  • 2290 return this.__validateConnectionCB();
  • }
  • },
  • @@ -1542,17 +1542,17 @@
  • };
  • 1var isBlank = function (obj) {
  • -
  • 334 var ret = false;
  • -
  • 334 if (isUndefinedOrNull(obj)) {
  • -
  • 281 ret = true;
  • -
  • 53 } else if (isString(obj) || isArray(obj)) {
  • -
  • 53 ret = obj.length === 0;
  • +
  • 755 var ret = false;
  • +
  • 755 if (isUndefinedOrNull(obj)) {
  • +
  • 666 ret = true;
  • +
  • 89 } else if (isString(obj) || isArray(obj)) {
  • +
  • 89 ret = obj.length === 0;
  • 0 } else if (isBoolean(obj) && !obj) {
  • 0 ret = true;
  • 0 } else if (isObject(obj) && isEmpty(obj)) {
  • 0 ret = true;
  • }
  • -
  • 334 return ret;
  • +
  • 755 return ret;
  • };
  • 1var byteaParser = function (val) {
  • @@ -1612,41 +1612,41 @@
  • },
  • query: function (query) {
  • -
  • 6357 var ret = new Promise();
  • -
  • 6357 try {
  • -
  • 6357 this.connection.setMaxListeners(0);
  • -
  • 6357 var fields = [];
  • -
  • 6357 var q = this.connection.query(query, function (err, results) {
  • -
  • 6357 q.handleRowDescription = orig;
  • -
  • 6357 if (err) {
  • +
  • 6393 var ret = new Promise();
  • +
  • 6393 try {
  • +
  • 6393 this.connection.setMaxListeners(0);
  • +
  • 6393 var fields = [];
  • +
  • 6393 var q = this.connection.query(query, function (err, results) {
  • +
  • 6393 q.handleRowDescription = orig;
  • +
  • 6393 if (err) {
  • 68 return ret.errback(err);
  • } else {
  • -
  • 6289 return ret.callback(results.rows, fields);
  • +
  • 6325 return ret.callback(results.rows, fields);
  • }
  • });
  • -
  • 6357 var orig = q.handleRowDescription;
  • -
  • 6357 q.handleRowDescription = function (msg) {
  • -
  • 3683 fields = msg.fields;
  • -
  • 3683 return orig.apply(q, arguments);
  • +
  • 6393 var orig = q.handleRowDescription;
  • +
  • 6393 q.handleRowDescription = function (msg) {
  • +
  • 3719 fields = msg.fields;
  • +
  • 3719 return orig.apply(q, arguments);
  • };
  • } catch (e) {
  • 0 patio.logError(e);
  • }
  • -
  • 6357 return ret.promise();
  • +
  • 6393 return ret.promise();
  • }
  • }
  • });
  • 1function colCallback(o) {
  • -
  • 24839 return o;
  • +
  • 27365 return o;
  • }
  • 1DS = define(Dataset, {
  • instance: {
  • complexExpressionSql: function (op, args) {
  • -
  • 5030 var ret = "";
  • -
  • 5030 if (op === "^") {
  • +
  • 5570 var ret = "";
  • +
  • 5570 if (op === "^") {
  • 0 var j = this._static.XOR_OP, c = false;
  • 0 args.forEach(function (a) {
  • 0 if (c) {
  • @@ -1656,7 +1656,7 @@
  • 0 c = true;
  • }, true);
  • } else {
  • -
  • 5030 return this._super(arguments);
  • +
  • 5570 return this._super(arguments);
  • }
  • 0 return ret;
  • },
  • @@ -1715,7 +1715,7 @@
  • },
  • _literalString: function (v) {
  • -
  • 5180 return "'" + v.replace(/\\/g, "\\\\").replace(/'/g, "''") + "'";
  • +
  • 5252 return "'" + v.replace(/\\/g, "\\\\").replace(/'/g, "''") + "'";
  • },
  • _deleteFromSql: function () {
  • @@ -1742,21 +1742,21 @@
  • },
  • _selectLockSql: function () {
  • -
  • 2619 if (this.__opts.lock === "share") {
  • +
  • 2655 if (this.__opts.lock === "share") {
  • 0 return this._static.FOR_SHARE;
  • } else {
  • -
  • 2619 return this._super(arguments);
  • +
  • 2655 return this._super(arguments);
  • }
  • },
  • _selectWithSql: function () {
  • -
  • 4631 var optsWith = this.__opts["with"];
  • -
  • 4631 if (!isEmpty(optsWith) && optsWith.some(function (w) {
  • +
  • 4667 var optsWith = this.__opts["with"];
  • +
  • 4667 if (!isEmpty(optsWith) && optsWith.some(function (w) {
  • 0 return w.recursive;
  • })) {
  • 0 return this._static.SQL_WITH_RECURSIVE;
  • } else {
  • -
  • 4631 return this._super(arguments);
  • +
  • 4667 return this._super(arguments);
  • }
  • },
  • @@ -1769,7 +1769,7 @@
  • },
  • _quotedIdentifier: function (c) {
  • -
  • 21320 return format('"%s"', c);
  • +
  • 23407 return format('"%s"', c);
  • },
  • __fullTextStringJoin: function (cols) {
  • @@ -1816,45 +1816,45 @@
  • },
  • fetchRows: function (sql) {
  • -
  • 2598 var oi = this.outputIdentifier.bind(this), self = this;
  • -
  • 2598 return asyncArray(this.execute(sql).chain(function (rows, fields) {
  • -
  • 2597 var cols = [];
  • -
  • 2597 if (rows && rows.length) {
  • -
  • 2213 self.__columns = [];
  • -
  • 2213 var col, colOutputIdentifier, i = -1, l;
  • -
  • 2213 if (fields && fields.length) {
  • +
  • 2634 var oi = this.outputIdentifier.bind(this), self = this;
  • +
  • 2634 return asyncArray(this.execute(sql).chain(function (rows, fields) {
  • +
  • 2633 var cols = [];
  • +
  • 2633 if (rows && rows.length) {
  • +
  • 2249 self.__columns = [];
  • +
  • 2249 var col, colOutputIdentifier, i = -1, l;
  • +
  • 2249 if (fields && fields.length) {
  • 0 l = fields.length;
  • 0 while (++i < l) {
  • 0 colOutputIdentifier = self.__columns[i] = oi(col = fields[i].name);
  • 0 cols[i] = [colOutputIdentifier, colCallback, col];
  • }
  • } else {
  • -
  • 2213 fields = Object.keys(rows[0]);
  • -
  • 2213 l = fields.length;
  • -
  • 2213 while (++i < l) {
  • -
  • 16812 colOutputIdentifier = self.__columns[i] = oi(col = fields[i]);
  • -
  • 16812 cols[i] = [colOutputIdentifier, colCallback, col];
  • +
  • 2249 fields = Object.keys(rows[0]);
  • +
  • 2249 l = fields.length;
  • +
  • 2249 while (++i < l) {
  • +
  • 17028 colOutputIdentifier = self.__columns[i] = oi(col = fields[i]);
  • +
  • 17028 cols[i] = [colOutputIdentifier, colCallback, col];
  • }
  • }
  • }
  • -
  • 2597 return self.__processRows(rows, cols);
  • +
  • 2633 return self.__processRows(rows, cols);
  • }));
  • },
  • __processRows: function (rows, cols) {
  • //dp this so the callbacks are called in appropriate order also.
  • -
  • 2597 var ret = [], i = -1, l = rows.length, j = -1, k = cols.length, row, h, col;
  • -
  • 2597 while (++i < l) {
  • -
  • 3178 row = rows[i];
  • -
  • 3178 h = {};
  • -
  • 3178 j = -1;
  • -
  • 3178 while (++j < k) {
  • -
  • 24839 col = cols[j];
  • -
  • 24839 h[col[0]] = col[1](row[col[2]]);
  • +
  • 2633 var ret = [], i = -1, l = rows.length, j = -1, k = cols.length, row, h, col;
  • +
  • 2633 while (++i < l) {
  • +
  • 3599 row = rows[i];
  • +
  • 3599 h = {};
  • +
  • 3599 j = -1;
  • +
  • 3599 while (++j < k) {
  • +
  • 27365 col = cols[j];
  • +
  • 27365 h[col[0]] = col[1](row[col[2]]);
  • }
  • -
  • 3178 ret[i] = h;
  • +
  • 3599 ret[i] = h;
  • }
  • -
  • 2597 return ret;
  • +
  • 2633 return ret;
  • },
  • @@ -1886,15 +1886,15 @@
  • },
  • supportsDistinctOn: function () {
  • -
  • 10879 return true;
  • +
  • 11311 return true;
  • },
  • supportsModifyingJoins: function () {
  • -
  • 12914 return true;
  • +
  • 13346 return true;
  • },
  • supportsTimestampTimezones: function () {
  • -
  • 10877 return true;
  • +
  • 11309 return true;
  • }
  • }
  • @@ -1965,23 +1965,23 @@
  • },
  • validate: function (conn) {
  • -
  • 1842 return new Promise().callback(true).promise();
  • +
  • 1878 return new Promise().callback(true).promise();
  • },
  • execute: function (sql, opts, conn) {
  • -
  • 4866 var self = this;
  • -
  • 4866 return when(conn || this._getConnection()).chain(function (conn) {
  • -
  • 4866 return self.__execute(conn, sql, opts);
  • +
  • 4902 var self = this;
  • +
  • 4902 return when(conn || this._getConnection()).chain(function (conn) {
  • +
  • 4902 return self.__execute(conn, sql, opts);
  • });
  • },
  • __execute: function (conn, sql, opts, cb) {
  • -
  • 4866 var self = this;
  • -
  • 4866 return this.__logAndExecute(sql, function () {
  • -
  • 4866 return conn.query(sql);
  • +
  • 4902 var self = this;
  • +
  • 4902 return this.__logAndExecute(sql, function () {
  • +
  • 4902 return conn.query(sql);
  • })
  • .both(function () {
  • -
  • 4866 return self._returnConnection(conn);
  • +
  • 4902 return self._returnConnection(conn);
  • });
  • },
  • @@ -2235,9 +2235,9 @@
  • schemaParseTable: function (tableName, opts) {
  • -
  • 57 var m = this.outputIdentifierFunc,
  • +
  • 93 var m = this.outputIdentifierFunc,
  • m2 = this.inputIdentifierFunc;
  • -
  • 57 var ds = this.metadataDataset
  • +
  • 93 var ds = this.metadataDataset
  • .select(
  • "pg_attribute__attname___name",
  • sql["format_type"]("pg_type__oid", "pg_attribute__atttypmod").as(literal('"dbType"')),
  • @@ -2255,26 +2255,26 @@
  • .filter({"pg_attribute__attnum": {gt: 0}})
  • .filter({"pg_class__relname": m2(tableName)})
  • .order("pg_attribute__attnum");
  • -
  • 57 ds = this.__filterSchema(ds, opts);
  • -
  • 57 var currentSchema = null, self = this;
  • -
  • 57 return ds.map(function (row) {
  • -
  • 334 var sch = row.nspname;
  • -
  • 334 delete row.nspname;
  • -
  • 334 if (currentSchema) {
  • -
  • 277 if (sch !== currentSchema) {
  • +
  • 93 ds = this.__filterSchema(ds, opts);
  • +
  • 93 var currentSchema = null, self = this;
  • +
  • 93 return ds.map(function (row) {
  • +
  • 755 var sch = row.nspname;
  • +
  • 755 delete row.nspname;
  • +
  • 755 if (currentSchema) {
  • +
  • 662 if (sch !== currentSchema) {
  • 0 var error = new Error("columns from two tables were returned please specify a schema");
  • 0 self.logError(error);
  • }
  • } else {
  • -
  • 57 currentSchema = sch;
  • +
  • 93 currentSchema = sch;
  • }
  • -
  • 334 if (isBlank(row["default"])) {
  • -
  • 281 row["default"] = null;
  • +
  • 755 if (isBlank(row["default"])) {
  • +
  • 666 row["default"] = null;
  • }
  • -
  • 334 row.type = self.schemaColumnType(row.dbType);
  • -
  • 334 var fieldName = m(row.name);
  • -
  • 334 delete row.name;
  • -
  • 334 return [fieldName, row];
  • +
  • 755 row.type = self.schemaColumnType(row.dbType);
  • +
  • 755 var fieldName = m(row.name);
  • +
  • 755 delete row.name;
  • +
  • 755 return [fieldName, row];
  • });
  • @@ -2312,14 +2312,14 @@
  • //If opts includes a :schema option, or a default schema is used, restrict the dataset to
  • // that schema. Otherwise, just exclude the default PostgreSQL schemas except for public.
  • __filterSchema: function (ds, opts) {
  • -
  • 57 opts = opts || {};
  • -
  • 57 var schema = opts.schema, ret = ds;
  • -
  • 57 if (schema) {
  • +
  • 93 opts = opts || {};
  • +
  • 93 var schema = opts.schema, ret = ds;
  • +
  • 93 if (schema) {
  • 0 ds = ds.filter({"pg_namespace__nspname": schema});
  • } else {
  • -
  • 57 ds = ds.exclude({"pg_namespace__nspname": this.EXCLUDE_SCHEMAS});
  • +
  • 93 ds = ds.exclude({"pg_namespace__nspname": this.EXCLUDE_SCHEMAS});
  • }
  • -
  • 57 return ds;
  • +
  • 93 return ds;
  • },
  • __notifySql: function (channel, payload) {
  • @@ -2457,7 +2457,7 @@
  • },
  • dataset: function () {
  • -
  • 659 return new DS(this);
  • +
  • 731 return new DS(this);
  • },
  • serialPrimaryKeyOptions: function () {
  • @@ -4318,14 +4318,14 @@
  • },
  • query: function (query) {
  • -
  • 281 var ret = new Promise();
  • -
  • 281 try {
  • -
  • 281 this.connection.setMaxListeners(0);
  • -
  • 281 this.connection.query(query, hitch(ret, ret.resolve));
  • +
  • 283 var ret = new Promise();
  • +
  • 283 try {
  • +
  • 283 this.connection.setMaxListeners(0);
  • +
  • 283 this.connection.query(query, hitch(ret, ret.resolve));
  • } catch (e) {
  • 0 patio.logError(e);
  • }
  • -
  • 281 return ret.promise();
  • +
  • 283 return ret.promise();
  • }
  • }
  • });
  • @@ -4557,38 +4557,38 @@
  • },
  • fetchRows: function (sql) {
  • -
  • 85 var self = this;
  • -
  • 85 return asyncArray(this.execute(sql).chain(function (r, fields) {
  • -
  • 85 var cols = [], i = -1, l = fields.length, col, fieldName, type, length, colIdentifier, selfCols = [];
  • -
  • 85 self.__columns = selfCols;
  • -
  • 85 while (++i < l) {
  • -
  • 292 col = fields[i];
  • -
  • 292 fieldName = col.name;
  • -
  • 292 type = col.type;
  • -
  • 292 length = col.fieldLength;
  • -
  • 292 colIdentifier = self.outputIdentifier(fieldName);
  • -
  • 292 selfCols[i] = colIdentifier;
  • -
  • 292 cols[i] = [colIdentifier, DB.convertMysqlType(type === 1 && length !== 1 ? 2 : type), fieldName];
  • +
  • 87 var self = this;
  • +
  • 87 return asyncArray(this.execute(sql).chain(function (r, fields) {
  • +
  • 87 var cols = [], i = -1, l = fields.length, col, fieldName, type, length, colIdentifier, selfCols = [];
  • +
  • 87 self.__columns = selfCols;
  • +
  • 87 while (++i < l) {
  • +
  • 304 col = fields[i];
  • +
  • 304 fieldName = col.name;
  • +
  • 304 type = col.type;
  • +
  • 304 length = col.fieldLength;
  • +
  • 304 colIdentifier = self.outputIdentifier(fieldName);
  • +
  • 304 selfCols[i] = colIdentifier;
  • +
  • 304 cols[i] = [colIdentifier, DB.convertMysqlType(type === 1 && length !== 1 ? 2 : type), fieldName];
  • }
  • -
  • 85 return self.__processRows(r, cols);
  • +
  • 87 return self.__processRows(r, cols);
  • }));
  • },
  • __processRows: function (rows, cols) {
  • //dp this so the callbacks are called in appropriate order also.
  • -
  • 85 var ret = [], i = -1, l = rows.length, j = -1, k = cols.length, row, h, col;
  • -
  • 85 while (++i < l) {
  • -
  • 112 row = rows[i];
  • -
  • 112 h = {};
  • -
  • 112 j = -1;
  • -
  • 112 while (++j < k) {
  • -
  • 432 col = cols[j];
  • -
  • 432 h[col[0]] = col[1](row[col[2]]);
  • +
  • 87 var ret = [], i = -1, l = rows.length, j = -1, k = cols.length, row, h, col;
  • +
  • 87 while (++i < l) {
  • +
  • 118 row = rows[i];
  • +
  • 118 h = {};
  • +
  • 118 j = -1;
  • +
  • 118 while (++j < k) {
  • +
  • 468 col = cols[j];
  • +
  • 468 h[col[0]] = col[1](row[col[2]]);
  • }
  • -
  • 109 ret[i] = h;
  • +
  • 115 ret[i] = h;
  • }
  • -
  • 82 return ret;
  • +
  • 84 return ret;
  • },
  • //Don't allow graphing a dataset that splits multiple statements
  • @@ -4636,8 +4636,8 @@
  • //Set the :type option to select if it hasn't been set.
  • execute: function (sql, opts) {
  • -
  • 85 opts = opts || {};
  • -
  • 85 return this._super([sql, merge({type: "select"}, opts)]);
  • +
  • 87 opts = opts || {};
  • +
  • 87 return this._super([sql, merge({type: "select"}, opts)]);
  • },
  • //Set the :type option to :select if it hasn't been set.
  • @@ -4706,23 +4706,23 @@
  • },
  • validate: function (conn) {
  • -
  • 263 return new Promise().callback(true).promise();
  • +
  • 265 return new Promise().callback(true).promise();
  • },
  • execute: function (sql, opts, conn) {
  • -
  • 263 var self = this;
  • -
  • 263 return when(conn || this._getConnection()).chain(function (conn) {
  • -
  • 263 return self.__execute(conn, sql, opts);
  • +
  • 265 var self = this;
  • +
  • 265 return when(conn || this._getConnection()).chain(function (conn) {
  • +
  • 265 return self.__execute(conn, sql, opts);
  • });
  • },
  • __execute: function (conn, sql, opts, cb) {
  • -
  • 263 var self = this;
  • -
  • 263 return this.__logAndExecute(sql, function () {
  • -
  • 263 return conn.query(sql);
  • +
  • 265 var self = this;
  • +
  • 265 return this.__logAndExecute(sql, function () {
  • +
  • 265 return conn.query(sql);
  • })
  • .both(function () {
  • -
  • 263 return self._returnConnection(conn);
  • +
  • 265 return self._returnConnection(conn);
  • });
  • },
  • @@ -4971,34 +4971,34 @@
  • //Use the MySQL specific DESCRIBE syntax to get a table description.
  • schemaParseTable: function (tableName, opts) {
  • -
  • 13 var m = this.outputIdentifierFunc, im = this.inputIdentifierFunc, self = this;
  • -
  • 13 return this.metadataDataset.withSql("DESCRIBE ?", sql.identifier(im(tableName))).map(function (row) {
  • -
  • 33 var ret = {};
  • -
  • 33 var e = row[m("Extra")];
  • -
  • 33 var allowNull = row[m("Null")];
  • -
  • 33 var key = row[m("Key")];
  • -
  • 33 ret.autoIncrement = e.match(/auto_increment/i) !== null;
  • -
  • 33 ret.allowNull = allowNull.match(/Yes/i) !== null;
  • -
  • 33 ret.primaryKey = key.match(/PRI/i) !== null;
  • -
  • 33 var defaultValue = row[m("Default")];
  • -
  • 33 ret["default"] = Buffer.isBuffer(defaultValue) ? defaultValue.toString() : defaultValue;
  • -
  • 33 if (isEmpty(row["default"])) {
  • -
  • 33 row["default"] = null;
  • +
  • 15 var m = this.outputIdentifierFunc, im = this.inputIdentifierFunc, self = this;
  • +
  • 15 return this.metadataDataset.withSql("DESCRIBE ?", sql.identifier(im(tableName))).map(function (row) {
  • +
  • 39 var ret = {};
  • +
  • 39 var e = row[m("Extra")];
  • +
  • 39 var allowNull = row[m("Null")];
  • +
  • 39 var key = row[m("Key")];
  • +
  • 39 ret.autoIncrement = e.match(/auto_increment/i) !== null;
  • +
  • 39 ret.allowNull = allowNull.match(/Yes/i) !== null;
  • +
  • 39 ret.primaryKey = key.match(/PRI/i) !== null;
  • +
  • 39 var defaultValue = row[m("Default")];
  • +
  • 39 ret["default"] = Buffer.isBuffer(defaultValue) ? defaultValue.toString() : defaultValue;
  • +
  • 39 if (isEmpty(row["default"])) {
  • +
  • 39 row["default"] = null;
  • }
  • -
  • 33 ret.dbType = row[m("Type")];
  • -
  • 33 if (Buffer.isBuffer(ret.dbType)) {
  • +
  • 39 ret.dbType = row[m("Type")];
  • +
  • 39 if (Buffer.isBuffer(ret.dbType)) {
  • //handle case for field type being returned at 252 (i.e. BLOB)
  • -
  • 33 ret.dbType = ret.dbType.toString();
  • +
  • 39 ret.dbType = ret.dbType.toString();
  • }
  • -
  • 33 ret.type = self.schemaColumnType(ret.dbType.toString("utf8"));
  • -
  • 33 var fieldName = m(row[m("Field")]);
  • -
  • 33 return [fieldName, ret];
  • +
  • 39 ret.type = self.schemaColumnType(ret.dbType.toString("utf8"));
  • +
  • 39 var fieldName = m(row[m("Field")]);
  • +
  • 39 return [fieldName, ret];
  • });
  • },
  • //Convert tinyint(1) type to boolean if convert_tinyint_to_bool is true
  • schemaColumnType: function (dbType) {
  • -
  • 33 return this._static.convertTinyintToBool && dbType === 'tinyint(1)' ? "boolean" : this._super(arguments);
  • +
  • 39 return this._static.convertTinyintToBool && dbType === 'tinyint(1)' ? "boolean" : this._super(arguments);
  • },
  • @@ -5022,7 +5022,7 @@
  • },
  • dataset: function () {
  • -
  • 136 return new DS(this);
  • +
  • 140 return new DS(this);
  • }
  • }
  • },
  • @@ -5072,14 +5072,14 @@
  • },
  • convertMysqlType: function (type) {
  • -
  • 292 var convert = this.convertTinyintToBool, convertDateTime = this.__convertInvalidDateTime, types = this.FIELD_TYPES;
  • -
  • 292 if (!patio) {
  • +
  • 304 var convert = this.convertTinyintToBool, convertDateTime = this.__convertInvalidDateTime, types = this.FIELD_TYPES;
  • +
  • 304 if (!patio) {
  • 1 patio = require("../index");
  • }
  • -
  • 292 return function (o) {
  • -
  • 432 var ret = o;
  • -
  • 432 if (o !== null) {
  • -
  • 317 switch (type) {
  • +
  • 304 return function (o) {
  • +
  • 468 var ret = o;
  • +
  • 468 if (o !== null) {
  • +
  • 347 switch (type) {
  • case types.FIELD_TYPE_TIMESTAMP:
  • case types.FIELD_TYPE_DATETIME:
  • 5 ret = convertDate(o, "stringToDateTime", convertDateTime);
  • @@ -5114,17 +5114,17 @@
  • case types.FIELD_TYPE_MEDIUM_BLOB:
  • case types.FIELD_TYPE_LONG_BLOB:
  • case types.FIELD_TYPE_BLOB:
  • -
  • 62 ret = new Buffer(o);
  • -
  • 62 break;
  • +
  • 68 ret = new Buffer(o);
  • +
  • 68 break;
  • }
  • }
  • -
  • 429 return ret;
  • +
  • 465 return ret;
  • };
  • },
  • getters: {
  • convertTinyintToBool: function () {
  • -
  • 325 return this.__convertTinyintToBool;
  • +
  • 343 return this.__convertTinyintToBool;
  • },
  • convertInvalidDateTime: function () {
  • @@ -6938,14 +6938,14 @@
  • * @property {Boolean} hasSelectSource true if this dataset already has a select sources.
  • */
  • constructor:function (db, opts) {
  • -
  • 25047 this._super(arguments);
  • -
  • 25047 this.db = db;
  • -
  • 25047 this.__opts = {};
  • -
  • 25047 this.__rowCb = null;
  • -
  • 25047 if (db) {
  • -
  • 12812 this.__quoteIdentifiers = db.quoteIdentifiers;
  • -
  • 12812 this.__identifierInputMethod = db.identifierInputMethod;
  • -
  • 12812 this.__identifierOutputMethod = db.identifierOutputMethod;
  • +
  • 26500 this._super(arguments);
  • +
  • 26500 this.db = db;
  • +
  • 26500 this.__opts = {};
  • +
  • 26500 this.__rowCb = null;
  • +
  • 26500 if (db) {
  • +
  • 13322 this.__quoteIdentifiers = db.quoteIdentifiers;
  • +
  • 13322 this.__identifierInputMethod = db.identifierInputMethod;
  • +
  • 13322 this.__identifierOutputMethod = db.identifierOutputMethod;
  • }
  • },
  • @@ -6960,22 +6960,22 @@
  • * @return [patio.Dataset] a cloned dataset with the merged options
  • **/
  • mergeOptions:function (opts) {
  • -
  • 13168 opts = isUndefined(opts) ? {} : opts;
  • -
  • 13168 var ds = new this._static(this.db, {});
  • -
  • 13168 ds.rowCb = this.rowCb;
  • -
  • 13168 this._static.FEATURES.forEach(function (f) {
  • -
  • 184352 ds[f] = this[f];
  • +
  • 13603 opts = isUndefined(opts) ? {} : opts;
  • +
  • 13603 var ds = new this._static(this.db, {});
  • +
  • 13603 ds.rowCb = this.rowCb;
  • +
  • 13603 this._static.FEATURES.forEach(function (f) {
  • +
  • 190442 ds[f] = this[f];
  • }, this);
  • -
  • 13168 var dsOpts = ds.__opts = merge({}, this.__opts, opts);
  • -
  • 13168 ds.identifierInputMethod = this.identifierInputMethod;
  • -
  • 13168 ds.identifierOutputMethod = this.identifierOutputMethod;
  • -
  • 13168 var columnChangeOpts = this._static.COLUMN_CHANGE_OPTS;
  • -
  • 13168 if (Object.keys(opts).some(function (o) {
  • -
  • 12002 return columnChangeOpts.indexOf(o) !== -1;
  • +
  • 13603 var dsOpts = ds.__opts = merge({}, this.__opts, opts);
  • +
  • 13603 ds.identifierInputMethod = this.identifierInputMethod;
  • +
  • 13603 ds.identifierOutputMethod = this.identifierOutputMethod;
  • +
  • 13603 var columnChangeOpts = this._static.COLUMN_CHANGE_OPTS;
  • +
  • 13603 if (Object.keys(opts).some(function (o) {
  • +
  • 12437 return columnChangeOpts.indexOf(o) !== -1;
  • })) {
  • -
  • 2288 dsOpts.columns = null;
  • +
  • 2542 dsOpts.columns = null;
  • }
  • -
  • 13168 return ds;
  • +
  • 13603 return ds;
  • },
  • @@ -7002,17 +7002,17 @@
  • * @return {patio.sql.Identifier|patio.sql.QualifiedIdentifier|patio.sql.AliasedExpression} an identifier generated based on the name string.
  • */
  • stringToIdentifier:function (name) {
  • -
  • 12656 if (isString(name)) {
  • -
  • 8628 var parts = this._splitString(name);
  • -
  • 8628 var schema = parts[0], table = parts[1], alias = parts[2];
  • -
  • 8628 return (schema && table && alias
  • +
  • 13922 if (isString(name)) {
  • +
  • 9568 var parts = this._splitString(name);
  • +
  • 9568 var schema = parts[0], table = parts[1], alias = parts[2];
  • +
  • 9568 return (schema && table && alias
  • ? new AliasedExpression(new QualifiedIdentifier(schema, table), alias)
  • : (schema && table
  • ? new QualifiedIdentifier(schema, table)
  • : (table && alias
  • ? new AliasedExpression(new Identifier(table), alias) : new Identifier(table))));
  • } else {
  • -
  • 4028 return name;
  • +
  • 4354 return name;
  • }
  • },
  • @@ -7040,20 +7040,20 @@
  • * </ul>
  • */
  • _splitString:function (s) {
  • -
  • 11616 var ret, m;
  • -
  • 11616 if ((m = s.match(this._static.COLUMN_REF_RE1)) !== null) {
  • -
  • 137 ret = m.slice(1);
  • +
  • 12871 var ret, m;
  • +
  • 12871 if ((m = s.match(this._static.COLUMN_REF_RE1)) !== null) {
  • +
  • 173 ret = m.slice(1);
  • }
  • -
  • 11479 else if ((m = s.match(this._static.COLUMN_REF_RE2)) !== null) {
  • +
  • 12698 else if ((m = s.match(this._static.COLUMN_REF_RE2)) !== null) {
  • 24 ret = [null, m[1], m[2]];
  • }
  • -
  • 11455 else if ((m = s.match(this._static.COLUMN_REF_RE3)) !== null) {
  • -
  • 1548 ret = [m[1], m[2], null];
  • +
  • 12674 else if ((m = s.match(this._static.COLUMN_REF_RE3)) !== null) {
  • +
  • 2160 ret = [m[1], m[2], null];
  • }
  • else {
  • -
  • 9907 ret = [null, s, null];
  • +
  • 10514 ret = [null, s, null];
  • }
  • -
  • 11616 return ret;
  • +
  • 12871 return ret;
  • },
  • /**
  • @@ -7062,31 +7062,31 @@
  • getters:{
  • rowCb:function () {
  • -
  • 18932 return this.__rowCb;
  • +
  • 19405 return this.__rowCb;
  • },
  • identifierInputMethod:function () {
  • -
  • 13168 return this.__identifierInputMethod;
  • +
  • 13603 return this.__identifierInputMethod;
  • },
  • identifierOutputMethod:function () {
  • -
  • 13168 return this.__identifierOutputMethod;
  • +
  • 13603 return this.__identifierOutputMethod;
  • },
  • firstSourceAlias:function () {
  • -
  • 450 var source = this.__opts.from;
  • -
  • 450 if (isUndefinedOrNull(source) || !source.length) {
  • +
  • 486 var source = this.__opts.from;
  • +
  • 486 if (isUndefinedOrNull(source) || !source.length) {
  • 2 throw new DatasetError("No source specified for the query");
  • }
  • -
  • 448 source = source[0];
  • -
  • 448 if (isInstanceOf(source, AliasedExpression)) {
  • +
  • 484 source = source[0];
  • +
  • 484 if (isInstanceOf(source, AliasedExpression)) {
  • 20 return source.alias;
  • -
  • 428 } else if (isString(source)) {
  • +
  • 464 } else if (isString(source)) {
  • 0 var parts = this._splitString(source);
  • 0 var alias = parts[2];
  • 0 return alias ? alias : source;
  • } else {
  • -
  • 428 return source;
  • +
  • 464 return source;
  • }
  • },
  • @@ -7129,16 +7129,16 @@
  • /**@lends patio.Dataset.prototype*/
  • identifierInputMethod:function (meth) {
  • -
  • 13238 this.__identifierInputMethod = meth;
  • +
  • 13673 this.__identifierInputMethod = meth;
  • },
  • identifierOutputMethod:function (meth) {
  • -
  • 13238 this.__identifierOutputMethod = meth;
  • +
  • 13673 this.__identifierOutputMethod = meth;
  • },
  • rowCb:function (cb) {
  • -
  • 16191 if (isFunction(cb) || isNull(cb)) {
  • -
  • 16186 this.__rowCb = cb;
  • +
  • 16626 if (isFunction(cb) || isNull(cb)) {
  • +
  • 16621 this.__rowCb = cb;
  • } else {
  • 5 throw new DatasetError("rowCb mus be a function");
  • }
  • @@ -7363,14 +7363,14 @@
  • * @borrows patio.Dataset#leftJoin as leftJoin
  • * */
  • constructor: function (options, fromDb) {
  • -
  • 2732 if (this.synced) {
  • -
  • 2732 this.__emitter = new EventEmitter();
  • -
  • 2732 this._super(arguments);
  • -
  • 2732 this.patio = patio || require("./index");
  • -
  • 2732 fromDb = isBoolean(fromDb) ? fromDb : false;
  • -
  • 2732 this.__changed = {};
  • -
  • 2732 this.__values = {};
  • -
  • 2732 if (fromDb) {
  • +
  • 2734 if (this.synced) {
  • +
  • 2734 this.__emitter = new EventEmitter();
  • +
  • 2734 this._super(arguments);
  • +
  • 2734 this.patio = patio || require("./index");
  • +
  • 2734 fromDb = isBoolean(fromDb) ? fromDb : false;
  • +
  • 2734 this.__changed = {};
  • +
  • 2734 this.__values = {};
  • +
  • 2734 if (fromDb) {
  • 1514 this._hook("pre", "load");
  • 1514 this.__isNew = false;
  • 1514 this.__setFromDb(options, true);
  • @@ -7379,8 +7379,8 @@
  • 1514 this._static.emit("load", this);
  • }
  • } else {
  • -
  • 1218 this.__isNew = true;
  • -
  • 1218 this.__set(options);
  • +
  • 1220 this.__isNew = true;
  • +
  • 1220 this.__set(options);
  • }
  • } else {
  • 0 throw new ModelError("Model " + this.tableName + " has not been synced");
  • @@ -7388,15 +7388,15 @@
  • },
  • __set: function (values, ignore) {
  • -
  • 1342 values = values || {};
  • -
  • 1342 this.__ignore = ignore === true;
  • -
  • 1342 Object.keys(values).forEach(function (attribute) {
  • +
  • 1344 values = values || {};
  • +
  • 1344 this.__ignore = ignore === true;
  • +
  • 1344 Object.keys(values).forEach(function (attribute) {
  • 5863 var value = values[attribute];
  • //check if the column is a constrained value and is allowed to be set
  • 5863 !ignore && this._checkIfColumnIsConstrained(attribute);
  • 5863 this[attribute] = value;
  • }, this);
  • -
  • 1342 this.__ignore = false;
  • +
  • 1344 this.__ignore = false;
  • },
  • __setFromDb: function (values, ignore) {
  • @@ -7651,7 +7651,7 @@
  • },
  • synced: function () {
  • -
  • 11266 return this._static.synced;
  • +
  • 11268 return this._static.synced;
  • }
  • }
  • @@ -9334,7 +9334,7 @@
  • * Proxy the quoteSchemaTable method to the dataset
  • * */
  • __quoteSchemaTable: function (table) {
  • -
  • 1963 return this.__schemaUtiltyDataset.quoteSchemaTable(table);
  • +
  • 1771 return this.__schemaUtiltyDataset.quoteSchemaTable(table);
  • },
  • /**
  • @@ -9582,8 +9582,8 @@
  • * @field
  • * */
  • __schemaUtiltyDataset: function () {
  • -
  • 2943 this.__schemaUtiltyDs = this.__schemaUtiltyDs || this.dataset;
  • -
  • 2943 return this.__schemaUtiltyDs;
  • +
  • 2751 this.__schemaUtiltyDs = this.__schemaUtiltyDs || this.dataset;
  • +
  • 2751 return this.__schemaUtiltyDs;
  • }
  • }
  • @@ -9675,9 +9675,9 @@
    - Coverage90.99 + Coverage90.93 SLOC2745 - LOC466 + LOC463 Missed42
    @@ -9705,36 +9705,34 @@
  • isString = comb.isString,
  • define = comb.define,
  • isRegExp = comb.isRegExp,
  • -
  • Dataset, patio;
  • +
  • Dataset, patio, sql, Expression, AliasedExpression, CaseExpression, Cast,
  • +
  • ColumnAll, BooleanExpression;
  • 1var virtualRow = function (name) {
  • -
  • 893 var WILDCARD = new LiteralString('*');
  • -
  • 893 var QUESTION_MARK = new LiteralString('?');
  • -
  • 893 var COMMA_SEPARATOR = new LiteralString(', ');
  • -
  • 893 var DOUBLE_UNDERSCORE = '__';
  • -
  • -
  • 893 var parts = name.split(DOUBLE_UNDERSCORE);
  • -
  • 893 var table = parts[0], column = parts[1];
  • -
  • 893 var ident = column ? QualifiedIdentifier.fromArgs([table, column]) : Identifier.fromArgs([name]);
  • -
  • 893 var prox = methodMissing(ident, function (m) {
  • +
  • 1242 var DOUBLE_UNDERSCORE = '__';
  • +
  • +
  • 1242 var parts = name.split(DOUBLE_UNDERSCORE);
  • +
  • 1242 var table = parts[0], column = parts[1];
  • +
  • 1242 var ident = column ? QualifiedIdentifier.fromArgs([table, column]) : Identifier.fromArgs([name]);
  • +
  • 1242 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);
  • -
  • 893 var ret = createFunctionWrapper(prox, function (m) {
  • -
  • 483 var args = argsToArray(arguments);
  • -
  • 483 if (args.length) {
  • -
  • 477 return SQLFunction.fromArgs([name].concat(args));
  • +
  • 1242 var ret = createFunctionWrapper(prox, function (m) {
  • +
  • 663 var args = argsToArray(arguments);
  • +
  • 663 if (args.length) {
  • +
  • 657 return SQLFunction.fromArgs([name].concat(args));
  • } else {
  • 6 return prox;
  • }
  • }, function () {
  • 0 return SQLFunction.fromArgs(arguments);
  • });
  • -
  • 893 ret.__proto__ = ident;
  • -
  • 893 return ret;
  • +
  • 1242 ret["__proto__"] = ident;
  • +
  • 1242 return ret;
  • };
  • 1var DATE_METHODS = ["getDate", "getDay", "getFullYear", "getHours", "getMilliseconds", "getMinutes", "getMonth", "getSeconds",
  • @@ -9747,7 +9745,7 @@
  • 1var addDateMethod = function (op) {
  • 180 return function () {
  • 4 return this.date[op].apply(this.date, arguments);
  • -
  • }
  • +
  • };
  • };
  • /**
  • @@ -9904,9 +9902,9 @@
  • */
  • 1var DateTime = function (y, m, d, h, min, s, ms) {
  • 83 var args = argsToArray(arguments);
  • -
  • 83 if(args.length === 0){
  • +
  • 83 if (args.length === 0) {
  • 0 this.date = new Date();
  • -
  • 83 }else if (isDate(y)) {
  • +
  • 83 } else if (isDate(y)) {
  • 77 this.date = y;
  • } else {
  • 6 var date = new Date(1970, 0, 1, 0, 0, 0);
  • @@ -10055,7 +10053,7 @@
  • * @name sql
  • * @memberOf patio
  • */
  • -
  • 1var sql = {
  • +
  • 1sql = {
  • /**@lends patio.sql*/
  • /**
  • @@ -10081,16 +10079,16 @@
  • *
  • * @return {patio.sql.Identifier|patio.sql.QualifiedIdentifier|patio.sql.AliasedExpression} an identifier generated based on the name string.
  • */
  • -
  • identifier:function (s) {
  • -
  • 1589 return sql.stringToIdentifier(s);
  • +
  • identifier: function (s) {
  • +
  • 1807 return sql.stringToIdentifier(s);
  • },
  • /**
  • * @see patio.sql.identifier
  • */
  • -
  • stringToIdentifier:function (name) {
  • -
  • 10264 !Dataset && (Dataset = require("./dataset"));
  • -
  • 10264 return new Dataset().stringToIdentifier(name);
  • +
  • stringToIdentifier: function (name) {
  • +
  • 11206 !Dataset && (Dataset = require("./dataset"));
  • +
  • 11206 return new Dataset().stringToIdentifier(name);
  • },
  • /**
  • @@ -10116,9 +10114,9 @@
  • * @return {patio.sql.LiteralString|patio.sql.PlaceHolderLiteralString} an expression that can be used as an argument
  • * for {@link patio.Dataset} query methods.
  • */
  • -
  • literal:function (s) {
  • -
  • 401 var args = argsToArray(arguments);
  • -
  • 401 return args.length > 1 ? PlaceHolderLiteralString.fromArgs(args) : new LiteralString(s);
  • +
  • literal: function (s) {
  • +
  • 545 var args = argsToArray(arguments);
  • +
  • 545 return args.length > 1 ? PlaceHolderLiteralString.fromArgs(args) : new LiteralString(s);
  • },
  • /**
  • @@ -10129,7 +10127,7 @@
  • * sql["case"]({a:sql.b}, sql.c, sql.d); //=> (CASE t.d WHEN t.a THEN t.b ELSE t.c END)
  • *
  • */
  • -
  • "case":function (hash, /*args**/opts) {
  • +
  • "case": function (hash, /*args**/opts) {
  • 2 var args = argsToArray(arguments, 1);
  • 2 return CaseExpression.fromArgs([hashToArray(hash)].concat(args));
  • },
  • @@ -10149,11 +10147,11 @@
  • * patio.sql.sqlStringJoin([sql.a, 'b']) # SQL: a || 'b'
  • * patio.sql.sqlStringJoin(['a', sql.b], ' '); //=> 'a' || ' ' || b
  • */
  • -
  • sqlStringJoin:function (arr, joiner) {
  • +
  • sqlStringJoin: function (arr, joiner) {
  • 6 joiner = joiner || null;
  • 6 var args;
  • 6 arr = arr.map(function (a) {
  • -
  • 12 return isInstanceOf(a, Expression, LiteralString, Boolean) || isNull(a) ? a : sql.stringToIdentifier(a)
  • +
  • 12 return isInstanceOf(a, Expression, LiteralString, Boolean) || isNull(a) ? a : sql.stringToIdentifier(a);
  • });
  • 6 if (joiner) {
  • 4 var newJoiner = [];
  • @@ -10171,83 +10169,85 @@
  • 6 return StringExpression.fromArgs(["||"].concat(args));
  • },
  • -
  • Year:Year,
  • -
  • TimeStamp:TimeStamp,
  • -
  • Time:Time,
  • -
  • DateTime:DateTime,
  • -
  • Float:Float,
  • -
  • Decimal:Decimal
  • +
  • Year: Year,
  • +
  • TimeStamp: TimeStamp,
  • +
  • Time: Time,
  • +
  • DateTime: DateTime,
  • +
  • Float: Float,
  • +
  • Decimal: Decimal
  • };
  • -
  • 1sql.__defineGetter__("patio", function () {
  • +
  • 1sql["__defineGetter__"]("patio", function () {
  • 0 !patio && (patio = require("./index"));
  • 0 return patio;
  • });
  • 1exports.sql = methodMissing(sql, function (name) {
  • -
  • 893 return virtualRow(name);
  • +
  • 1242 return virtualRow(name);
  • });
  • 1var OPERTATOR_INVERSIONS = {
  • -
  • AND:"OR",
  • -
  • OR:"AND",
  • -
  • GT:"lte",
  • -
  • GTE:"lt",
  • -
  • LT:"gte",
  • -
  • LTE:"gt",
  • -
  • EQ:"neq",
  • -
  • NEQ:"eq",
  • -
  • LIKE:'NOT LIKE',
  • -
  • "NOT LIKE":"LIKE",
  • -
  • '!~*':'~*',
  • -
  • '~*':'!~*',
  • -
  • "~":'!~',
  • -
  • "IN":'NOTIN',
  • -
  • "NOTIN":"IN",
  • -
  • "IS":'IS NOT',
  • -
  • "ISNOT":"IS",
  • -
  • NOT:"NOOP",
  • -
  • NOOP:"NOT",
  • -
  • ILIKE:'NOT ILIKE',
  • -
  • NOTILIKE:"ILIKE"
  • +
  • AND: "OR",
  • +
  • OR: "AND",
  • +
  • GT: "lte",
  • +
  • GTE: "lt",
  • +
  • LT: "gte",
  • +
  • LTE: "gt",
  • +
  • EQ: "neq",
  • +
  • NEQ: "eq",
  • +
  • LIKE: 'NOT LIKE',
  • +
  • "NOT LIKE": "LIKE",
  • +
  • '!~*': '~*',
  • +
  • '~*': '!~*',
  • +
  • "~": '!~',
  • +
  • "IN": 'NOTIN',
  • +
  • "NOTIN": "IN",
  • +
  • "IS": 'IS NOT',
  • +
  • "ISNOT": "IS",
  • +
  • NOT: "NOOP",
  • +
  • NOOP: "NOT",
  • +
  • ILIKE: 'NOT ILIKE',
  • +
  • NOTILIKE: "ILIKE"
  • };
  • // Standard mathematical operators used in +NumericMethods+
  • -
  • 1var MATHEMATICAL_OPERATORS = {PLUS:"+", MINUS:"-", DIVIDE:"/", MULTIPLY:"*"};
  • +
  • 1var MATHEMATICAL_OPERATORS = {PLUS: "+", MINUS: "-", DIVIDE: "/", MULTIPLY: "*"};
  • // Bitwise mathematical operators used in +NumericMethods+
  • -
  • 1var BITWISE_OPERATORS = {bitWiseAnd:"&", bitWiseOr:"|", exclusiveOr:"^", leftShift:"<<", rightShift:">>"};
  • +
  • 1var BITWISE_OPERATORS = {bitWiseAnd: "&", bitWiseOr: "|", exclusiveOr: "^", leftShift: "<<", rightShift: ">>"};
  • -
  • 1var INEQUALITY_OPERATORS = {GT:">", GTE:">=", LT:"<", LTE:"<="};
  • +
  • 1var INEQUALITY_OPERATORS = {GT: ">", GTE: ">=", LT: "<", LTE: "<="};
  • //Hash of ruby operator symbols to SQL operators, used in +BooleanMethods+
  • -
  • 1var BOOLEAN_OPERATORS = {AND:"AND", OR:"OR"};
  • +
  • 1var BOOLEAN_OPERATORS = {AND: "AND", OR: "OR"};
  • //Operators that use IN/NOT IN for inclusion/exclusion
  • -
  • 1var IN_OPERATORS = {IN:"IN", NOTIN:'NOT IN'};
  • +
  • 1var IN_OPERATORS = {IN: "IN", NOTIN: 'NOT IN'};
  • //Operators that use IS, used for special casing to override literal true/false values
  • -
  • 1var IS_OPERATORS = {IS:"IS", ISNOT:'IS NOT'};
  • +
  • 1var IS_OPERATORS = {IS: "IS", ISNOT: 'IS NOT'};
  • //Operator symbols that take exactly two arguments
  • 1var TWO_ARITY_OPERATORS = merge({
  • -
  • EQ:'=',
  • -
  • NEQ:'!=', LIKE:"LIKE",
  • -
  • "NOT LIKE":'NOT LIKE',
  • -
  • ILIKE:"ILIKE",
  • -
  • "NOT ILIKE":'NOT ILIKE',
  • -
  • "~":"~",
  • -
  • '!~':"!~",
  • -
  • '~*':"~*",
  • -
  • '!~*':"!~*"}, INEQUALITY_OPERATORS, BITWISE_OPERATORS, IS_OPERATORS, IN_OPERATORS);
  • +
  • EQ: '=',
  • +
  • NEQ: '!=',
  • +
  • LIKE: "LIKE",
  • +
  • "NOT LIKE": 'NOT LIKE',
  • +
  • ILIKE: "ILIKE",
  • +
  • "NOT ILIKE": 'NOT ILIKE',
  • +
  • "~": "~",
  • +
  • '!~': "!~",
  • +
  • '~*': "~*",
  • +
  • '!~*': "!~*"
  • +
  • }, INEQUALITY_OPERATORS, BITWISE_OPERATORS, IS_OPERATORS, IN_OPERATORS);
  • //Operator symbols that take one or more arguments
  • -
  • 1var N_ARITY_OPERATORS = merge({"||":"||"}, BOOLEAN_OPERATORS, MATHEMATICAL_OPERATORS);
  • +
  • 1var N_ARITY_OPERATORS = merge({"||": "||"}, BOOLEAN_OPERATORS, MATHEMATICAL_OPERATORS);
  • //Operator symbols that take only a single argument
  • -
  • 1var ONE_ARITY_OPERATORS = {"NOT":"NOT", "NOOP":"NOOP"};
  • +
  • 1var ONE_ARITY_OPERATORS = {"NOT": "NOT", "NOOP": "NOOP"};
  • /**
  • * @class Mixin to provide alias methods to an expression.
  • @@ -10256,7 +10256,7 @@
  • * @memberOf patio.sql
  • */
  • 1var AliasMethods = define(null, {
  • -
  • instance:{
  • +
  • instance: {
  • /**@lends patio.sql.AliasMethods.prototype*/
  • /**
  • @@ -10272,8 +10272,8 @@
  • *
  • * @return {patio.sql.AliasedExpression} the aliased expression.
  • */
  • -
  • as:function (alias) {
  • -
  • 495 return new AliasedExpression(this, alias);
  • +
  • as: function (alias) {
  • +
  • 639 return new AliasedExpression(this, alias);
  • }
  • }
  • @@ -10287,7 +10287,7 @@
  • else {
  • 0 return new BooleanExpression(op, this, expression);
  • }
  • -
  • }
  • +
  • };
  • };
  • /**
  • @@ -10305,7 +10305,7 @@
  • * @memberOf patio.sql
  • */
  • 1var BitWiseMethods = define(null, {
  • -
  • instance:{
  • +
  • instance: {
  • /**@lends patio.sql.BitWiseMethods.prototype*/
  • /**
  • @@ -10314,7 +10314,7 @@
  • * @example
  • * sql.a.sqlNumber.bitWiseAnd("b"); //=> "a" & "b"
  • */
  • -
  • bitWiseAnd:bitWiseMethod("bitWiseAnd"),
  • +
  • bitWiseAnd: bitWiseMethod("bitWiseAnd"),
  • /**
  • * Bitwise or
  • @@ -10322,7 +10322,7 @@
  • * @example
  • * sql.a.sqlNumber.bitWiseOr("b") //=> "a" | "b"
  • */
  • -
  • bitWiseOr:bitWiseMethod("bitWiseOr"),
  • +
  • bitWiseOr: bitWiseMethod("bitWiseOr"),
  • /**
  • * Exclusive Or
  • @@ -10331,7 +10331,7 @@
  • *
  • * sql.a.sqlNumber.exclusiveOr("b") //=> "a" ^ "b"
  • */
  • -
  • exclusiveOr:bitWiseMethod("exclusiveOr"),
  • +
  • exclusiveOr: bitWiseMethod("exclusiveOr"),
  • /**
  • * Bitwise shift left
  • @@ -10340,7 +10340,7 @@
  • *
  • * sql.a.sqlNumber.leftShift("b") // "a" << "b"
  • */
  • -
  • leftShift:bitWiseMethod("leftShift"),
  • +
  • leftShift: bitWiseMethod("leftShift"),
  • /**
  • * Bitwise shift right
  • @@ -10349,7 +10349,7 @@
  • *
  • * sql.a.sqlNumber.rightShift("b") //=> "a" >> "b"
  • */
  • -
  • rightShift:bitWiseMethod("rightShift")
  • +
  • rightShift: bitWiseMethod("rightShift")
  • }
  • }).as(sql, "BitWiseMethods");
  • @@ -10361,7 +10361,7 @@
  • else {
  • 7 return new BooleanExpression(op, this, expression);
  • }
  • -
  • }
  • +
  • };
  • };
  • /**
  • @@ -10378,7 +10378,7 @@
  • * @memberOf patio.sql
  • */
  • 1var BooleanMethods = define(null, {
  • -
  • instance:{
  • +
  • instance: {
  • /**@lends patio.sql.BooleanMethods.prototype*/
  • /**
  • @@ -10392,7 +10392,7 @@
  • *
  • * @return {patio.sql.BooleanExpression} a ANDed boolean expression.
  • */
  • -
  • and:booleanMethod("and"),
  • +
  • and: booleanMethod("and"),
  • /**
  • * @function
  • @@ -10404,7 +10404,7 @@
  • *
  • * @return {patio.sql.BooleanExpression} a ORed boolean expression
  • */
  • -
  • or:booleanMethod("or"),
  • +
  • or: booleanMethod("or"),
  • /**
  • * Logical NOT
  • @@ -10415,7 +10415,7 @@
  • *
  • * @return {patio.sql.BooleanExpression} a inverted boolean expression.
  • */
  • -
  • not:function () {
  • +
  • not: function () {
  • 5 return BooleanExpression.invert(this);
  • }
  • @@ -10429,7 +10429,7 @@
  • * @memberOf patio.sql
  • */
  • 1var CastMethods = define(null, {
  • -
  • instance:{
  • +
  • instance: {
  • /**@lends patio.sql.CastMethods.prototype*/
  • /**
  • * Cast the reciever to the given SQL type.
  • @@ -10441,7 +10441,7 @@
  • *
  • * @return {patio.sql.Cast} the casted expression
  • */
  • -
  • cast:function (type) {
  • +
  • cast: function (type) {
  • 2 return new Cast(this, type);
  • },
  • @@ -10457,7 +10457,7 @@
  • *
  • * @return {patio.sql.NumericExpression} a casted numberic expression
  • */
  • -
  • castNumeric:function (type) {
  • +
  • castNumeric: function (type) {
  • 0 return this.cast(type || "integer").sqlNumber;
  • },
  • @@ -10473,7 +10473,7 @@
  • *
  • * @return {patio.sql.StringExpression} the casted string expression
  • */
  • -
  • castString:function (type) {
  • +
  • castString: function (type) {
  • 0 return this.cast(type || String).sqlString;
  • }
  • }
  • @@ -10500,14 +10500,14 @@
  • * </pre>
  • */
  • 1var ComplexExpressionMethods = define(null, {
  • -
  • instance:{
  • +
  • instance: {
  • /**@ignore*/
  • -
  • getters:{
  • +
  • getters: {
  • /**
  • * @ignore
  • */
  • -
  • sqlBoolean:function () {
  • +
  • sqlBoolean: function () {
  • 0 return new BooleanExpression("noop", this);
  • },
  • @@ -10515,7 +10515,7 @@
  • /**
  • * @ignore
  • */
  • -
  • sqlFunction:function () {
  • +
  • sqlFunction: function () {
  • 13 return new SQLFunction(this);
  • },
  • @@ -10523,14 +10523,14 @@
  • /**
  • * @ignore
  • */
  • -
  • sqlNumber:function () {
  • +
  • sqlNumber: function () {
  • 50 return new NumericExpression("noop", this);
  • },
  • /**
  • * @ignore
  • */
  • -
  • sqlString:function () {
  • +
  • sqlString: function () {
  • 0 return new StringExpression("noop", this);
  • }
  • }
  • @@ -10539,16 +10539,16 @@
  • 1var inequalityMethod = function (op) {
  • 6 return function (expression) {
  • -
  • 88 if (isInstanceOf(expression, BooleanExpression)
  • -
  • || isBoolean(expression)
  • -
  • || isNull(expression)
  • -
  • || (isHash(expression))
  • -
  • || isArray(expression)) {
  • +
  • 88 if (isInstanceOf(expression, BooleanExpression) ||
  • +
  • isBoolean(expression) ||
  • +
  • isNull(expression) ||
  • +
  • (isHash(expression)) ||
  • +
  • isArray(expression)) {
  • 0 throw new ExpressionError("Cannot apply " + op + " to a boolean expression");
  • } else {
  • 88 return new BooleanExpression(op, this, expression);
  • }
  • -
  • }
  • +
  • };
  • };
  • /**
  • @@ -10566,7 +10566,7 @@
  • * @memberOf patio.sql
  • */
  • 1var InequalityMethods = define(null, {
  • -
  • instance:{
  • +
  • instance: {
  • /**@lends patio.sql.InequalityMethods.prototype*/
  • /**
  • @@ -10577,7 +10577,7 @@
  • *
  • * @return {patio.sql.BooleanExpression}
  • */
  • -
  • gt:inequalityMethod("gt"),
  • +
  • gt: inequalityMethod("gt"),
  • /**
  • * @function Creates a gte {@link patio.sql.BooleanExpression} compared to this expression.
  • *
  • @@ -10587,7 +10587,7 @@
  • *
  • * @return {patio.sql.BooleanExpression}
  • */
  • -
  • gte:inequalityMethod("gte"),
  • +
  • gte: inequalityMethod("gte"),
  • /**
  • * @function Creates a lt {@link patio.sql.BooleanExpression} compared to this expression.
  • *
  • @@ -10597,7 +10597,7 @@
  • *
  • * @return {patio.sql.BooleanExpression}
  • */
  • -
  • lt:inequalityMethod("lt"),
  • +
  • lt: inequalityMethod("lt"),
  • /**
  • * @function Creates a lte {@link patio.sql.BooleanExpression} compared to this expression.
  • *
  • @@ -10607,7 +10607,7 @@
  • *
  • * @return {patio.sql.BooleanExpression}
  • */
  • -
  • lte:inequalityMethod("lte"),
  • +
  • lte: inequalityMethod("lte"),
  • /**
  • * @function Creates a eq {@link patio.sql.BooleanExpression} compared to this expression.
  • *
  • @@ -10617,9 +10617,9 @@
  • *
  • * @return {patio.sql.BooleanExpression}
  • */
  • -
  • eq:inequalityMethod("eq"),
  • +
  • eq: inequalityMethod("eq"),
  • -
  • neq:inequalityMethod("neq"),
  • +
  • neq: inequalityMethod("neq"),
  • /**
  • * @private
  • @@ -10635,8 +10635,8 @@
  • *
  • * @return {patio.sql.BooleanExpression} a boolean expression containing the between expression.
  • */
  • -
  • between:function (items) {
  • -
  • 6 return new BooleanExpression("AND", new BooleanExpression("gte", this, items[0]), new BooleanExpression("lte", this, items[1]))
  • +
  • between: function (items) {
  • +
  • 6 return new BooleanExpression("AND", new BooleanExpression("gte", this, items[0]), new BooleanExpression("lte", this, items[1]));
  • }
  • }
  • }).as(sql, "InequalityMethods");
  • @@ -10650,15 +10650,15 @@
  • * @memberOf patio.sql
  • */
  • 1var NoBooleanInputMethods = define(null, {
  • -
  • instance:{
  • -
  • constructor:function (op) {
  • +
  • instance: {
  • +
  • constructor: function (op) {
  • 22 var args = argsToArray(arguments, 1);
  • 22 args.forEach(function (expression) {
  • -
  • 26 if ((isInstanceOf(expression, BooleanExpression))
  • -
  • || isBoolean(expression)
  • -
  • || isNull(expression)
  • -
  • || (isObject(expression) && !isInstanceOf(expression, Expression, Dataset, LiteralString))
  • -
  • || isArray(expression)) {
  • +
  • 26 if ((isInstanceOf(expression, BooleanExpression)) ||
  • +
  • isBoolean(expression) ||
  • +
  • isNull(expression) ||
  • +
  • (isObject(expression) && !isInstanceOf(expression, Expression, Dataset, LiteralString)) ||
  • +
  • isArray(expression)) {
  • 0 throw new ExpressionError("Cannot apply " + op + " to a boolean expression");
  • }
  • });
  • @@ -10674,7 +10674,7 @@
  • } else {
  • 12 return new NumericExpression(op, this, expression);
  • }
  • -
  • }
  • +
  • };
  • };
  • @@ -10692,7 +10692,7 @@
  • * @memberOf patio.sql
  • */
  • 1var NumericMethods = define(null, {
  • -
  • instance:{
  • +
  • instance: {
  • /**@lends patio.sql.NumericMethods.prototype*/
  • @@ -10705,7 +10705,7 @@
  • *
  • * @return {patio.sql.NumericExpression}
  • */
  • -
  • plus:numericMethod("plus"),
  • +
  • plus: numericMethod("plus"),
  • /**
  • * @function Subtracts the provided expression from this expression and returns a {@link patio.sql.NumericExpression}.
  • @@ -10716,7 +10716,7 @@
  • *
  • * @return {patio.sql.NumericExpression}
  • */
  • -
  • minus:numericMethod("minus"),
  • +
  • minus: numericMethod("minus"),
  • /**
  • * @function Divides this expression by the provided expression and returns a {@link patio.sql.NumericExpression}.
  • @@ -10727,7 +10727,7 @@
  • *
  • * @return {patio.sql.NumericExpression}
  • */
  • -
  • divide:numericMethod("divide"),
  • +
  • divide: numericMethod("divide"),
  • /**
  • * @function Divides this expression by the provided expression and returns a {@link patio.sql.NumericExpression}.
  • @@ -10738,7 +10738,7 @@
  • *
  • * @return {patio.sql.NumericExpression}
  • */
  • -
  • multiply:numericMethod("multiply")
  • +
  • multiply: numericMethod("multiply")
  • }
  • }).as(sql, "NumericMethods");
  • @@ -10757,7 +10757,7 @@
  • * @memberOf patio.sql
  • */
  • 1var OrderedMethods = define(null, {
  • -
  • instance:{
  • +
  • instance: {
  • /**@lends patio.sql.OrderedMethods.prototype*/
  • /**
  • @@ -10772,7 +10772,7 @@
  • * before other values), or "last" to use NULLS LAST (so NULL values are ordered after other values).
  • * @return {patio.sql.OrderedExpression}
  • */
  • -
  • asc:function (options) {
  • +
  • asc: function (options) {
  • 7 return new OrderedExpression(this, false, options);
  • },
  • @@ -10788,7 +10788,7 @@
  • * before other values), or "last" to use NULLS LAST (so NULL values are ordered after other values).
  • * @return {patio.sql.OrderedExpression}
  • */
  • -
  • desc:function (options) {
  • +
  • desc: function (options) {
  • 26 return new OrderedExpression(this, true, options);
  • }
  • }
  • @@ -10808,7 +10808,7 @@
  • * @memberOf patio.sql
  • */
  • 1var QualifyingMethods = define(null, {
  • -
  • instance:{
  • +
  • instance: {
  • /**@lends patio.sql.QualifyingMethods.prototype*/
  • /**
  • @@ -10823,8 +10823,8 @@
  • *
  • * @return {patio.sql.QualifiedIdentifier}
  • */
  • -
  • qualify:function (qualifier) {
  • -
  • 439 return new QualifiedIdentifier(qualifier, this);
  • +
  • qualify: function (qualifier) {
  • +
  • 511 return new QualifiedIdentifier(qualifier, this);
  • },
  • /**
  • @@ -10837,7 +10837,7 @@
  • *
  • * @return {patio.sql.ColumnAll}
  • */
  • -
  • all:function () {
  • +
  • all: function () {
  • 208 return new ColumnAll(this);
  • }
  • @@ -10859,7 +10859,7 @@
  • * @memberOf patio.sql
  • */
  • 1var StringMethods = define(null, {
  • -
  • instance:{
  • +
  • instance: {
  • /**@lends patio.sql.StringMethods.prototype*/
  • /**
  • @@ -10871,10 +10871,10 @@
  • *
  • * @return {patio.sql.BooleanExpression}
  • */
  • -
  • ilike:function (expression) {
  • +
  • ilike: function (expression) {
  • 278 expression = argsToArray(arguments);
  • 278 return StringExpression.like.apply(StringExpression, [this].concat(expression).concat([
  • -
  • {caseInsensitive:true}
  • +
  • {caseInsensitive: true}
  • ]));
  • },
  • @@ -10888,7 +10888,7 @@
  • *
  • * @param expression
  • */
  • -
  • like:function (expression) {
  • +
  • like: function (expression) {
  • 11 expression = argsToArray(arguments);
  • 11 return StringExpression.like.apply(StringExpression, [this].concat(expression));
  • }
  • @@ -10906,7 +10906,7 @@
  • * @memberOf patio.sql
  • */
  • 1var StringConcatenationMethods = define(null, {
  • -
  • instance:{
  • +
  • instance: {
  • /**@lends patio.sql.StringConcatenationMethods.prototype*/
  • /**
  • @@ -10919,7 +10919,7 @@
  • *
  • * @param expression expression to concatenate this expression with.
  • */
  • -
  • concat:function (expression) {
  • +
  • concat: function (expression) {
  • 0 return new StringExpression("||", this, expression);
  • }
  • }
  • @@ -10937,7 +10937,7 @@
  • * @memberOf patio.sql
  • */
  • 1var SubscriptMethods = define(null, {
  • -
  • instance:{
  • +
  • instance: {
  • /**
  • * Return a {@link patio.sql.Subscript} with the given arguments, representing an
  • @@ -10950,7 +10950,7 @@
  • *
  • * @param subscript
  • */
  • -
  • sqlSubscript:function (subscript) {
  • +
  • sqlSubscript: function (subscript) {
  • 64 var args = argsToArray(arguments);
  • 64 return new SubScript(this, flatten(args));
  • }
  • @@ -10964,9 +10964,9 @@
  • * @name Expression
  • * @memberOf patio.sql
  • */
  • -
  • 1var Expression = define(null, {
  • +
  • 1Expression = define(null, {
  • -
  • instance:{
  • +
  • instance: {
  • /**@lends patio.sql.Expression.prototype*/
  • /**
  • @@ -10975,13 +10975,13 @@
  • * @param {patio.Dataset} ds the dataset that will be used to SQL-ify this expression.
  • * @return {String} a string literal version of this expression.
  • */
  • -
  • sqlLiteral:function (ds) {
  • +
  • sqlLiteral: function (ds) {
  • 0 return this.toString(ds);
  • }
  • },
  • -
  • static:{
  • +
  • static: {
  • /**@lends patio.sql.Expression*/
  • /**
  • @@ -10995,14 +10995,14 @@
  • *
  • * @return {patio.sql.Expression} an expression.
  • */
  • -
  • fromArgs:function (args) {
  • -
  • 1974 var ret;
  • -
  • 1974 try {
  • -
  • 1974 ret = new this();
  • +
  • fromArgs: function (args) {
  • +
  • 2612 var ret, Self = this;
  • +
  • 2612 try {
  • +
  • 2612 ret = new Self();
  • } catch (ignore) {
  • }
  • -
  • 1974 this.apply(ret, args);
  • -
  • 1974 return ret;
  • +
  • 2612 this.apply(ret, args);
  • +
  • 2612 return ret;
  • },
  • /**
  • @@ -11018,9 +11018,9 @@
  • * @param {*} obj object to test if it is a condition specifier
  • * @return {Boolean} true if the object is a Hash or is an array of two element arrays.
  • */
  • -
  • isConditionSpecifier:function (obj) {
  • -
  • 18738 return isHash(obj) || (isArray(obj) && obj.length && obj.every(function (i) {
  • -
  • 7840 return isArray(i) && i.length === 2;
  • +
  • isConditionSpecifier: function (obj) {
  • +
  • 20908 return isHash(obj) || (isArray(obj) && obj.length && obj.every(function (i) {
  • +
  • 8670 return isArray(i) && i.length === 2;
  • }));
  • }
  • }
  • @@ -11047,8 +11047,8 @@
  • 1var GenericExpression = define([Expression, AliasMethods, BooleanMethods, CastMethods, ComplexExpressionMethods, InequalityMethods, NumericMethods, OrderedMethods, StringMethods, SubscriptMethods]).as(sql, "GenericExpression");
  • -
  • 1var AliasedExpression = define(Expression, {
  • -
  • instance:{
  • +
  • 1AliasedExpression = define(Expression, {
  • +
  • instance: {
  • /**@lends patio.sql.AliasedExpression.prototype*/
  • /**
  • @@ -11064,9 +11064,9 @@
  • * @property alias the alias of the expression
  • *
  • */
  • -
  • constructor:function (expression, alias) {
  • -
  • 835 this.expression = expression;
  • -
  • 835 this.alias = alias;
  • +
  • constructor: function (expression, alias) {
  • +
  • 1015 this.expression = expression;
  • +
  • 1015 this.alias = alias;
  • },
  • /**
  • @@ -11076,18 +11076,18 @@
  • *
  • * @return String the SQL alias fragment.
  • */
  • -
  • toString:function (ds) {
  • -
  • 767 !Dataset && (Dataset = require("./dataset"));
  • -
  • 767 ds = ds || new Dataset();
  • -
  • 767 return ds.aliasedExpressionSql(this);
  • +
  • toString: function (ds) {
  • +
  • 947 !Dataset && (Dataset = require("./dataset"));
  • +
  • 947 ds = ds || new Dataset();
  • +
  • 947 return ds.aliasedExpressionSql(this);
  • }
  • }
  • }
  • ).as(sql, "AliasedExpression");
  • -
  • 1var CaseExpression = define(GenericExpression, {
  • -
  • instance:{
  • +
  • 1CaseExpression = define(GenericExpression, {
  • +
  • instance: {
  • /**@lends patio.sql.CaseExpression.prototype*/
  • /**
  • @@ -11108,7 +11108,7 @@
  • * @property expression the expression of the {@link patio.sql.CaseExpression}.
  • * @property {Boolean} noExpression true if this {@link patio.sql.CaseExpression}'s expression is undefined.
  • */
  • -
  • constructor:function (conditions, def, expression) {
  • +
  • constructor: function (conditions, def, expression) {
  • 8 if (Expression.isConditionSpecifier(conditions)) {
  • 4 this.conditions = toArray(conditions);
  • 4 this.def = def;
  • @@ -11125,16 +11125,16 @@
  • *
  • * @return String the SQL case expression fragment.
  • */
  • -
  • toString:function (ds) {
  • +
  • toString: function (ds) {
  • 2 !Dataset && (Dataset = require("./dataset"));
  • 2 ds = ds || new Dataset();
  • 2 return ds.caseExpressionSql(this);
  • },
  • /**@ignore*/
  • -
  • getters:{
  • +
  • getters: {
  • /**@ignore*/
  • -
  • hasExpression:function () {
  • +
  • hasExpression: function () {
  • 2 return !this.noExpression;
  • }
  • }
  • @@ -11142,8 +11142,8 @@
  • }).as(sql, "CaseExpression");
  • -
  • 1var Cast = define(GenericExpression, {
  • -
  • instance:{
  • +
  • 1Cast = define(GenericExpression, {
  • +
  • instance: {
  • /**@lends patio.sql.Cast*/
  • /**
  • @@ -11157,7 +11157,7 @@
  • * @property expr the expression to CAST.
  • * @property type the type to CAST the expression to.
  • */
  • -
  • constructor:function (expr, type) {
  • +
  • constructor: function (expr, type) {
  • 3 this.expr = expr;
  • 3 this.type = type;
  • },
  • @@ -11170,7 +11170,7 @@
  • *
  • * @return String the SQL cast expression fragment.
  • */
  • -
  • toString:function (ds) {
  • +
  • toString: function (ds) {
  • 2 !Dataset && (Dataset = require("./dataset"));
  • 2 ds = ds || new Dataset();
  • 2 return ds.castSql(this.expr, this.type);
  • @@ -11179,8 +11179,8 @@
  • }).as(sql, "Cast");
  • -
  • 1var ColumnAll = define(Expression, {
  • -
  • instance:{
  • +
  • 1ColumnAll = define(Expression, {
  • +
  • instance: {
  • /**@lends patio.sql.ColumnAll.prototype*/
  • /**
  • @@ -11193,7 +11193,7 @@
  • *
  • * @property table the table this all column expression represents.
  • */
  • -
  • constructor:function (table) {
  • +
  • constructor: function (table) {
  • 225 this.table = table;
  • },
  • @@ -11205,7 +11205,7 @@
  • *
  • * @return String the SQL columnAll expression fragment.
  • */
  • -
  • toString:function (ds) {
  • +
  • toString: function (ds) {
  • 224 !Dataset && (Dataset = require("./dataset"));
  • 224 ds = ds || new Dataset();
  • 224 return ds.columnAllSql(this);
  • @@ -11214,7 +11214,7 @@
  • }).as(sql, "ColumnAll");
  • 1var ComplexExpression = define([Expression, AliasMethods, CastMethods, OrderedMethods, SubscriptMethods], {
  • -
  • instance:{
  • +
  • instance: {
  • /**@lends patio.sql.ComplexExpression.prototype*/
  • /**
  • @@ -11243,47 +11243,47 @@
  • * other than the second arg for an IN/NOT IN operator.</li>
  • * </p>
  • */
  • -
  • constructor:function (op) {
  • -
  • 6490 if (op) {
  • -
  • 5898 var args = argsToArray(arguments,1 );
  • +
  • constructor: function (op) {
  • +
  • 7251 if (op) {
  • +
  • 6550 var args = argsToArray(arguments, 1);
  • //make a copy of the args
  • -
  • 5898 var origArgs = args.slice(0);
  • -
  • 5898 args.forEach(function (a, i) {
  • -
  • 11968 if (Expression.isConditionSpecifier(a)) {
  • +
  • 6550 var origArgs = args.slice(0);
  • +
  • 6550 args.forEach(function (a, i) {
  • +
  • 13272 if (Expression.isConditionSpecifier(a)) {
  • 6 args[i] = BooleanExpression.fromValuePairs(a);
  • }
  • });
  • -
  • 5898 op = op.toUpperCase();
  • +
  • 6550 op = op.toUpperCase();
  • -
  • 5898 if (N_ARITY_OPERATORS.hasOwnProperty(op)) {
  • -
  • 925 if (args.length < 1) {
  • -
  • 0 throw new ExpressionError("The " + op + " operator requires at least 1 argument")
  • +
  • 6550 if (N_ARITY_OPERATORS.hasOwnProperty(op)) {
  • +
  • 1107 if (args.length < 1) {
  • +
  • 0 throw new ExpressionError("The " + op + " operator requires at least 1 argument");
  • }
  • -
  • 925 var oldArgs = args.slice(0);
  • -
  • 925 args = [];
  • -
  • 925 oldArgs.forEach(function (a) {
  • -
  • 2085 a instanceof ComplexExpression && a.op == op ? args = args.concat(a.args) : args.push(a);
  • +
  • 1107 var oldArgs = args.slice(0);
  • +
  • 1107 args = [];
  • +
  • 1107 oldArgs.forEach(function (a) {
  • +
  • 2449 a instanceof ComplexExpression && a.op === op ? args = args.concat(a.args) : args.push(a);
  • });
  • -
  • 4973 } else if (TWO_ARITY_OPERATORS.hasOwnProperty(op)) {
  • -
  • 4910 if (args.length != 2) {
  • +
  • 5443 } else if (TWO_ARITY_OPERATORS.hasOwnProperty(op)) {
  • +
  • 5380 if (args.length !== 2) {
  • 0 throw new ExpressionError("The " + op + " operator requires precisely 2 arguments");
  • }
  • //With IN/NOT IN, even if the second argument is an array of two element arrays,
  • //don't convert it into a boolean expression, since it's definitely being used
  • //as a value list.
  • -
  • 4910 if (IN_OPERATORS[op]) {
  • -
  • 23 args[1] = origArgs[1]
  • +
  • 5380 if (IN_OPERATORS[op]) {
  • +
  • 23 args[1] = origArgs[1];
  • }
  • 63 } else if (ONE_ARITY_OPERATORS.hasOwnProperty(op)) {
  • -
  • 63 if (args.length != 1) {
  • +
  • 63 if (args.length !== 1) {
  • 0 throw new ExpressionError("The " + op + " operator requires only one argument");
  • }
  • } else {
  • 0 throw new ExpressionError("Invalid operator " + op);
  • }
  • -
  • 5898 this.op = op;
  • -
  • 5898 this.args = args;
  • +
  • 6550 this.op = op;
  • +
  • 6550 this.args = args;
  • }
  • },
  • @@ -11295,14 +11295,14 @@
  • *
  • * @return String the SQL version of the {@link patio.sql.ComplexExpression}.
  • */
  • -
  • toString:function (ds) {
  • -
  • 5666 !Dataset && (Dataset = require("./dataset"));
  • -
  • 5666 ds = ds || new Dataset();
  • -
  • 5666 return ds.complexExpressionSql(this.op, this.args);
  • +
  • toString: function (ds) {
  • +
  • 6211 !Dataset && (Dataset = require("./dataset"));
  • +
  • 6211 ds = ds || new Dataset();
  • +
  • 6211 return ds.complexExpressionSql(this.op, this.args);
  • }
  • },
  • -
  • static:{
  • +
  • static: {
  • /**@lends patio.sql.ComplexExpression*/
  • /**
  • @@ -11332,7 +11332,7 @@
  • * NOTILIKE:"ILIKE"
  • * }
  • */
  • -
  • OPERATOR_INVERSIONS:OPERTATOR_INVERSIONS,
  • +
  • OPERATOR_INVERSIONS: OPERTATOR_INVERSIONS,
  • /**
  • * Default mathematical operators.
  • @@ -11340,7 +11340,7 @@
  • * @type Object
  • * @default {PLUS:"+", MINUS:"-", DIVIDE:"/", MULTIPLY:"*"}
  • */
  • -
  • MATHEMATICAL_OPERATORS:MATHEMATICAL_OPERATORS,
  • +
  • MATHEMATICAL_OPERATORS: MATHEMATICAL_OPERATORS,
  • /**
  • * Default bitwise operators.
  • @@ -11348,14 +11348,14 @@
  • * @type Object
  • * @default {bitWiseAnd:"&", bitWiseOr:"|", exclusiveOr:"^", leftShift:"<<", rightShift:">>"}
  • */
  • -
  • BITWISE_OPERATORS:BITWISE_OPERATORS,
  • +
  • BITWISE_OPERATORS: BITWISE_OPERATORS,
  • /**
  • * Default inequality operators.
  • *
  • * @type Object
  • * @default {GT:">",GTE:">=",LT:"<",LTE:"<="}
  • */
  • -
  • INEQUALITY_OPERATORS:INEQUALITY_OPERATORS,
  • +
  • INEQUALITY_OPERATORS: INEQUALITY_OPERATORS,
  • /**
  • * Default boolean operators.
  • @@ -11363,7 +11363,7 @@
  • * @type Object
  • * @default {AND:"AND",OR:"OR"}
  • */
  • -
  • BOOLEAN_OPERATORS:BOOLEAN_OPERATORS,
  • +
  • BOOLEAN_OPERATORS: BOOLEAN_OPERATORS,
  • /**
  • * Default IN operators.
  • @@ -11371,14 +11371,14 @@
  • * @type Object
  • * @default {IN:"IN",NOTIN:'NOT IN'}
  • */
  • -
  • IN_OPERATORS:IN_OPERATORS,
  • +
  • IN_OPERATORS: IN_OPERATORS,
  • /**
  • * Default IS operators.
  • *
  • * @type Object
  • * @default {IS:"IS", ISNOT:'IS NOT'}
  • */
  • -
  • IS_OPERATORS:IS_OPERATORS,
  • +
  • IS_OPERATORS: IS_OPERATORS,
  • /**
  • * Default two arity operators.
  • *
  • @@ -11408,7 +11408,7 @@
  • * NOTIN:'NOT IN'
  • * }
  • */
  • -
  • TWO_ARITY_OPERATORS:TWO_ARITY_OPERATORS,
  • +
  • TWO_ARITY_OPERATORS: TWO_ARITY_OPERATORS,
  • /**
  • * Default N(multi) arity operators.
  • @@ -11423,7 +11423,7 @@
  • * DIVIDE:"/", MULTIPLY:"*"
  • * }
  • */
  • -
  • N_ARITY_OPERATORS:N_ARITY_OPERATORS,
  • +
  • N_ARITY_OPERATORS: N_ARITY_OPERATORS,
  • /**
  • * Default ONE operators.
  • @@ -11434,7 +11434,7 @@
  • * "NOOP":"NOOP"
  • * }
  • */
  • -
  • ONE_ARITY_OPERATORS:ONE_ARITY_OPERATORS
  • +
  • ONE_ARITY_OPERATORS: ONE_ARITY_OPERATORS
  • }
  • }).as(sql, "ComplexExpression");
  • @@ -11448,8 +11448,8 @@
  • * @name BooleanExpression
  • * @memberOf patio.sql
  • */
  • -
  • 1var BooleanExpression = define([ComplexExpression, BooleanMethods], {
  • -
  • static:{
  • +
  • 1BooleanExpression = define([ComplexExpression, BooleanMethods], {
  • +
  • static: {
  • /**@lends patio.sql.BooleanExpression*/
  • /**
  • @@ -11466,17 +11466,17 @@
  • *
  • * @return {patio.sql.BooleanExpression} the inverted expression.
  • */
  • -
  • invert:function (expression) {
  • -
  • 87 if (isInstanceOf(expression, BooleanExpression)) {
  • -
  • 82 var op = expression.op, newArgs;
  • -
  • 82 if (op == "AND" || op == "OR") {
  • +
  • invert: function (expression) {
  • +
  • 123 if (isInstanceOf(expression, BooleanExpression)) {
  • +
  • 118 var op = expression.op, newArgs;
  • +
  • 118 if (op === "AND" || op === "OR") {
  • 3 newArgs = [OPERTATOR_INVERSIONS[op]].concat(expression.args.map(function (arg) {
  • 6 return BooleanExpression.invert(arg);
  • }));
  • 3 return BooleanExpression.fromArgs(newArgs);
  • } else {
  • -
  • 79 newArgs = [OPERTATOR_INVERSIONS[op]].concat(expression.args);
  • -
  • 79 return BooleanExpression.fromArgs(newArgs);
  • +
  • 115 newArgs = [OPERTATOR_INVERSIONS[op]].concat(expression.args);
  • +
  • 115 return BooleanExpression.fromArgs(newArgs);
  • }
  • 5 } else if (isInstanceOf(expression, StringExpression) || isInstanceOf(expression, NumericExpression)) {
  • 0 throw new ExpressionError(format("Cannot invert %4j", [expression]));
  • @@ -11514,41 +11514,41 @@
  • * </pre>
  • * @return {patio.sql.BooleanExpression} expression composed of sub expressions built from the hash.
  • */
  • -
  • fromValuePairs:function (a, op, negate) {
  • -
  • 6566 !Dataset && (Dataset = require("./dataset"));
  • -
  • 6566 op = op || "AND", negate = negate || false;
  • -
  • 6566 var pairArr = [];
  • -
  • 6566 var isArr = isArray(a) && Expression.isConditionSpecifier(a);
  • -
  • 6566 if (isHash(a)) {
  • -
  • 2967 pairArr.push(this.__filterObject(a));
  • +
  • fromValuePairs: function (a, op, negate) {
  • +
  • 7073 !Dataset && (Dataset = require("./dataset"));
  • +
  • 7073 op = op || "AND", negate = negate || false;
  • +
  • 7073 var pairArr = [];
  • +
  • 7073 var isArr = isArray(a) && Expression.isConditionSpecifier(a);
  • +
  • 7073 if (isHash(a)) {
  • +
  • 3148 pairArr.push(this.__filterObject(a, null, op));
  • } else {
  • -
  • 3599 for (var k in a) {
  • -
  • 4224 var v = isArr ? a[k][1] : a[k], ret;
  • -
  • 4224 k = isArr ? a[k][0] : k;
  • -
  • 4224 if (isArray(v) || isInstanceOf(v, Dataset)) {
  • +
  • 3925 for (var k in a) {
  • +
  • 4622 var v = isArr ? a[k][1] : a[k], ret;
  • +
  • 4622 k = isArr ? a[k][0] : k;
  • +
  • 4622 if (isArray(v) || isInstanceOf(v, Dataset)) {
  • 17 k = isArray(k) ? k.map(function (i) {
  • -
  • 12 return isString(i) ? sql.stringToIdentifier(i) : i
  • +
  • 12 return isString(i) ? sql.stringToIdentifier(i) : i;
  • }) : isString(k) ? sql.stringToIdentifier(k) : k;
  • 17 ret = new BooleanExpression("IN", k, v);
  • -
  • 4207 } else if (isInstanceOf(v, NegativeBooleanConstant)) {
  • +
  • 4605 } else if (isInstanceOf(v, NegativeBooleanConstant)) {
  • 0 ret = new BooleanExpression("ISNOT", k, v.constant);
  • -
  • 4207 } else if (isInstanceOf(v, BooleanConstant)) {
  • +
  • 4605 } else if (isInstanceOf(v, BooleanConstant)) {
  • 0 ret = new BooleanExpression("IS", k, v.constant);
  • -
  • 4207 } else if (isNull(v) || isBoolean(v)) {
  • -
  • 180 ret = new BooleanExpression("IS", k, v);
  • -
  • 4027 } else if (isHash(v)) {
  • -
  • 0 ret = BooleanExpression.__filterObject(v, k);
  • -
  • 4027 } else if (isRegExp(v)) {
  • -
  • 61 ret = StringExpression.like(sql.stringToIdentifier(k), v);
  • +
  • 4605 } else if (isNull(v) || isBoolean(v)) {
  • +
  • 252 ret = new BooleanExpression("IS", k, v);
  • +
  • 4353 } else if (isHash(v)) {
  • +
  • 0 ret = BooleanExpression.__filterObject(v, k, op);
  • +
  • 4353 } else if (isRegExp(v)) {
  • +
  • 97 ret = StringExpression.like(sql.stringToIdentifier(k), v);
  • } else {
  • -
  • 3966 ret = new BooleanExpression("EQ", sql.stringToIdentifier(k), v);
  • +
  • 4256 ret = new BooleanExpression("EQ", sql.stringToIdentifier(k), v);
  • }
  • -
  • 4224 negate && (ret = BooleanExpression.invert(ret));
  • -
  • 4224 pairArr.push(ret);
  • +
  • 4622 negate && (ret = BooleanExpression.invert(ret));
  • +
  • 4622 pairArr.push(ret);
  • }
  • }
  • //if We just have one then return the first otherwise create a new Boolean expression
  • -
  • 6566 return pairArr.length == 1 ? pairArr[0] : BooleanExpression.fromArgs([op].concat(pairArr));
  • +
  • 7073 return pairArr.length == 1 ? pairArr[0] : BooleanExpression.fromArgs([op].concat(pairArr));
  • },
  • /**
  • @@ -11572,33 +11572,33 @@
  • *
  • * @return {patio.sql.Expression} an expression to use in the filter
  • */
  • -
  • __filterObject:function (expr, key) {
  • -
  • 3076 var pairs = [], opts, newKey;
  • -
  • 3076 var twoArityOperators = this.TWO_ARITY_OPERATORS;
  • -
  • 3076 for (var k in expr) {
  • -
  • 3100 var v = expr[k];
  • -
  • 3100 if (isHash(v)) { //its a hash too filter it too!
  • -
  • 107 pairs.push(this.__filterObject(v, k));
  • -
  • 2993 } else if (key && (twoArityOperators[k.toUpperCase()] || k.match(/between/i))) {
  • +
  • __filterObject: function (expr, key, op) {
  • +
  • 3293 var pairs = [], opts, newKey;
  • +
  • 3293 var twoArityOperators = this.TWO_ARITY_OPERATORS;
  • +
  • 3293 for (var k in expr) {
  • +
  • 3318 var v = expr[k];
  • +
  • 3318 if (isHash(v)) { //its a hash too filter it too!
  • +
  • 143 pairs.push(this.__filterObject(v, k, op));
  • +
  • 3175 } else if (key && (twoArityOperators[k.toUpperCase()] || k.match(/between/i))) {
  • //its a two arrity operator (e.g. '=', '>')
  • -
  • 110 newKey = isString(key) ? key.split(",") : [key];
  • -
  • 110 if (newKey.length > 1) {
  • +
  • 146 newKey = isString(key) ? key.split(",") : [key];
  • +
  • 146 if (newKey.length > 1) {
  • //this represents a hash where the key represents two columns
  • //(e.g. {"col1,col2" : 1}) => WHERE (col1 = 1 AND col2 = 1)
  • 1 pairs = pairs.concat(newKey.map(function (k) {
  • //filter each column with the expression
  • -
  • 2 return this.__filterObject(expr, k);
  • +
  • 2 return this.__filterObject(expr, k, op);
  • }, this));
  • } else {
  • -
  • 109 newKey = [sql.stringToIdentifier(newKey[0])];
  • -
  • 109 if (k.match(/^like$/)) {
  • +
  • 145 newKey = [sql.stringToIdentifier(newKey[0])];
  • +
  • 145 if (k.match(/^like$/)) {
  • //its a like clause {col : {like : "hello"}}
  • 3 pairs.push(StringExpression.like.apply(StringExpression, (newKey.concat(isArray(v) ? v : [v]))));
  • -
  • 106 } else if (k.match(/^iLike$/)) {
  • +
  • 142 } else if (k.match(/^iLike$/)) {
  • //its a like clause {col : {iLike : "hello"}}
  • -
  • 2 pairs.push(StringExpression.like.apply(StringExpression, (newKey.concat(isArray(v) ? v : [v]).concat({caseInsensitive:true}))));
  • -
  • 104 } else if (k.match(/between/i)) {
  • +
  • 2 pairs.push(StringExpression.like.apply(StringExpression, (newKey.concat(isArray(v) ? v : [v]).concat({caseInsensitive: true}))));
  • +
  • 140 } else if (k.match(/between/i)) {
  • //its a like clause {col : {between : [1,10]}}
  • 6 var between = sql.stringToIdentifier(newKey[0]).between(v);
  • 6 k == "notBetween" && (between = between.not());
  • @@ -11607,32 +11607,32 @@
  • //otherwise is just a boolean expressio
  • //it its not a valid operator then we
  • //BooleanExpression with throw an error
  • -
  • 98 pairs.push(new BooleanExpression(k, newKey[0], v));
  • +
  • 134 pairs.push(new BooleanExpression(k, newKey[0], v));
  • }
  • }
  • } else {
  • //we're not a twoarity operator
  • //so we create a boolean expression out of it
  • -
  • 2883 newKey = k.split(",");
  • -
  • 2883 if (newKey.length == 1) {
  • -
  • 2877 newKey = sql.stringToIdentifier(newKey[0]);
  • +
  • 3029 newKey = k.split(",");
  • +
  • 3029 if (newKey.length == 1) {
  • +
  • 3023 newKey = sql.stringToIdentifier(newKey[0]);
  • }
  • -
  • 2883 opts = [
  • +
  • 3029 opts = [
  • [newKey, v]
  • ];
  • -
  • 2883 pairs.push(BooleanExpression.fromValuePairs(opts));
  • +
  • 3029 pairs.push(BooleanExpression.fromValuePairs(opts));
  • }
  • }
  • //if the total of pairs is one then we just return the first element
  • //otherwise we join them all with an AND
  • -
  • 3076 return pairs.length == 1 ? pairs[0] : BooleanExpression.fromArgs(["AND"].concat(pairs));
  • +
  • 3293 return pairs.length == 1 ? pairs[0] : BooleanExpression.fromArgs([op || "AND"].concat(pairs));
  • }
  • }
  • }).as(sql, "BooleanExpression");
  • 1var Constant = define(GenericExpression, {
  • -
  • instance:{
  • +
  • instance: {
  • /**@lends patio.sql.Constant.prototype*/
  • /**
  • * Represents constants or psuedo-constants (e.g.'CURRENT_DATE) in SQL.
  • @@ -11641,7 +11641,7 @@
  • * @augments patio.sql.GenericExpression
  • * @property {String} constant <b>READ ONLY</b> the contant.
  • */
  • -
  • constructor:function (constant) {
  • +
  • constructor: function (constant) {
  • 18 this.__constant = constant;
  • },
  • @@ -11653,14 +11653,14 @@
  • *
  • * @return String the SQL version of the {@link patio.sql.Constant}.
  • */
  • -
  • toString:function (ds) {
  • +
  • toString: function (ds) {
  • 6 !Dataset && (Dataset = require("./dataset"));
  • 6 ds = ds || new Dataset();
  • 6 return ds.constantSql(this.__constant);
  • },
  • -
  • getters:{
  • -
  • constant:function () {
  • +
  • getters: {
  • +
  • constant: function () {
  • 0 return this.__constant;
  • }
  • }
  • @@ -11674,7 +11674,7 @@
  • * @memberOf patio.sql
  • */
  • 1var BooleanConstant = define(Constant, {
  • -
  • instance:{
  • +
  • instance: {
  • /**@lends patio.sql.BooleanConstant.prototype*/
  • /**
  • @@ -11685,7 +11685,7 @@
  • *
  • * @return String the SQL version of the {@link patio.sql.BooleanConstant}.
  • */
  • -
  • toString:function (ds) {
  • +
  • toString: function (ds) {
  • 10 !Dataset && (Dataset = require("./dataset"));
  • 10 ds = ds || new Dataset();
  • 10 return ds.booleanConstantSql(this.__constant);
  • @@ -11702,7 +11702,7 @@
  • * @memberOf patio.sql
  • */
  • 1var NegativeBooleanConstant = define(BooleanConstant, {
  • -
  • instance:{
  • +
  • instance: {
  • /**@lends patio.sql.NegativeBooleanConstant.prototype*/
  • /**
  • @@ -11713,7 +11713,7 @@
  • *
  • * @return String the SQL version of the {@link patio.sql.NegativeBooleanConstant}.
  • */
  • -
  • toString:function (ds) {
  • +
  • toString: function (ds) {
  • 2 !Dataset && (Dataset = require("./dataset"));
  • 2 ds = ds || new Dataset();
  • 2 return ds.negativeBooleanConstantSql(this.__constant);
  • @@ -11734,61 +11734,61 @@
  • * Constant for CURRENT DATE
  • * @type patio.sql.Constant
  • */
  • -
  • CURRENT_DATE:new Constant("CURRENT_DATE"),
  • +
  • CURRENT_DATE: new Constant("CURRENT_DATE"),
  • /**
  • * Constant for CURRENT TIME
  • * @type patio.sql.Constant
  • */
  • -
  • CURRENT_TIME:new Constant("CURRENT_TIME"),
  • +
  • CURRENT_TIME: new Constant("CURRENT_TIME"),
  • /**
  • * Constant for CURRENT TIMESTAMP
  • * @type patio.sql.Constant
  • */
  • -
  • CURRENT_TIMESTAMP:new Constant("CURRENT_TIMESTAMP"),
  • +
  • CURRENT_TIMESTAMP: new Constant("CURRENT_TIMESTAMP"),
  • /**
  • * Constant for TRUE
  • * @type patio.sql.BooleanConstant
  • */
  • -
  • SQLTRUE:new BooleanConstant(1),
  • +
  • SQLTRUE: new BooleanConstant(1),
  • /**
  • * Constant for TRUE
  • * @type patio.sql.BooleanConstant
  • */
  • -
  • TRUE:new BooleanConstant(1),
  • +
  • TRUE: new BooleanConstant(1),
  • /**
  • * Constant for FALSE.
  • * @type patio.sql.BooleanConstant
  • */
  • -
  • SQLFALSE:new BooleanConstant(0),
  • +
  • SQLFALSE: new BooleanConstant(0),
  • /**
  • * Constant for FALSE
  • * @type patio.sql.BooleanConstant
  • */
  • -
  • FALSE:new BooleanConstant(0),
  • +
  • FALSE: new BooleanConstant(0),
  • /**
  • * Constant for NULL
  • * @type patio.sql.BooleanConstant
  • */
  • -
  • NULL:new BooleanConstant(null),
  • +
  • NULL: new BooleanConstant(null),
  • /**
  • * Constant for NOT NULL
  • * @type patio.sql.NegativeBooleanConstant
  • */
  • -
  • NOTNULL:new NegativeBooleanConstant(null)
  • +
  • NOTNULL: new NegativeBooleanConstant(null)
  • };
  • 1var Constants = sql.Constants
  • 1var Identifier = define([GenericExpression, QualifyingMethods], {
  • -
  • instance:{
  • +
  • instance: {
  • /**@lends patio.sql.Identifier.prototype*/
  • /**
  • @@ -11804,8 +11804,8 @@
  • *
  • * @property {String} value <b>READ ONLY</b> the column or table this identifier represents.
  • */
  • -
  • constructor:function (value) {
  • -
  • 14657 this.__value = value;
  • +
  • constructor: function (value) {
  • +
  • 15647 this.__value = value;
  • },
  • /**
  • @@ -11816,23 +11816,23 @@
  • *
  • * @return String the SQL version of the {@link patio.sql.Identifier}.
  • */
  • -
  • toString:function (ds) {
  • -
  • 19188 !Dataset && (Dataset = require("./dataset"));
  • -
  • 19188 ds = ds || new Dataset();
  • -
  • 19188 return ds.quoteIdentifier(this);
  • +
  • toString: function (ds) {
  • +
  • 19554 !Dataset && (Dataset = require("./dataset"));
  • +
  • 19554 ds = ds || new Dataset();
  • +
  • 19554 return ds.quoteIdentifier(this);
  • },
  • /**@ignore*/
  • -
  • getters:{
  • -
  • value:function () {
  • -
  • 22083 return this.__value;
  • +
  • getters: {
  • +
  • value: function () {
  • +
  • 22700 return this.__value;
  • }
  • }
  • }
  • }).as(sql, "Identifier");
  • 1var JoinClause = define(Expression, {
  • -
  • instance:{
  • +
  • instance: {
  • /**@lends patio.sql.JoinClause.prototype*/
  • /**
  • @@ -11849,10 +11849,10 @@
  • * @property table <b>READ ONLY</b> the table to join with
  • * @property joinType <b>READ ONLY</b> the alias to use for this join clause
  • * */
  • -
  • constructor:function (joinType, table, tableAlias) {
  • -
  • 630 this.__joinType = joinType;
  • -
  • 630 this.__table = table;
  • -
  • 630 this.__tableAlias = tableAlias || null;
  • +
  • constructor: function (joinType, table, tableAlias) {
  • +
  • 810 this.__joinType = joinType;
  • +
  • 810 this.__table = table;
  • +
  • 810 this.__tableAlias = tableAlias || null;
  • },
  • /**
  • @@ -11863,24 +11863,24 @@
  • *
  • * @return String the SQL version of the {@link patio.sql.JoinClause}.
  • */
  • -
  • toString:function (ds) {
  • +
  • toString: function (ds) {
  • 17 !Dataset && (Dataset = require("./dataset"));
  • 17 ds = ds || new Dataset();
  • 17 return ds.joinClauseSql(this);
  • },
  • /**@ignore*/
  • -
  • getters:{
  • -
  • joinType:function () {
  • -
  • 773 return this.__joinType;
  • +
  • getters: {
  • +
  • joinType: function () {
  • +
  • 953 return this.__joinType;
  • },
  • -
  • table:function () {
  • -
  • 774 return this.__table;
  • +
  • table: function () {
  • +
  • 954 return this.__table;
  • },
  • -
  • tableAlias:function () {
  • -
  • 772 return this.__tableAlias;
  • +
  • tableAlias: function () {
  • +
  • 952 return this.__tableAlias;
  • }
  • }
  • }
  • @@ -11888,7 +11888,7 @@
  • 1var JoinOnClause = define(JoinClause, {
  • -
  • instance:{
  • +
  • instance: {
  • /**@lends patio.sql.JoinOnClause.prototype*/
  • /**
  • * Represents an SQL JOIN clause with ON conditions. Created by {@link patio.Dataset} join methods.
  • @@ -11899,9 +11899,9 @@
  • * @param on the expression to filter with. See {@link patio.Dataset#filter}
  • * @property on <b>READ ONLY</b> the filter to use with joining the datasets.
  • */
  • -
  • constructor:function (on, joinType, table, tableAlias) {
  • -
  • 600 this.__on = on;
  • -
  • 600 this._super(arguments, [joinType, table, tableAlias]);
  • +
  • constructor: function (on, joinType, table, tableAlias) {
  • +
  • 780 this.__on = on;
  • +
  • 780 this._super(arguments, [joinType, table, tableAlias]);
  • },
  • /**
  • @@ -11912,16 +11912,16 @@
  • *
  • * @return String the SQL version of the {@link patio.sql.JoinOnClause}.
  • */
  • -
  • toString:function (ds) {
  • -
  • 652 !Dataset && (Dataset = require("./dataset"));
  • -
  • 652 ds = ds || new Dataset();
  • -
  • 652 return ds.joinOnClauseSql(this);
  • +
  • toString: function (ds) {
  • +
  • 832 !Dataset && (Dataset = require("./dataset"));
  • +
  • 832 ds = ds || new Dataset();
  • +
  • 832 return ds.joinOnClauseSql(this);
  • },
  • /**@ignore*/
  • -
  • getters:{
  • -
  • on:function () {
  • -
  • 652 return this.__on;
  • +
  • getters: {
  • +
  • on: function () {
  • +
  • 832 return this.__on;
  • }
  • }
  • }
  • @@ -11929,7 +11929,7 @@
  • 1var JoinUsingClause = define(JoinClause, {
  • -
  • instance:{
  • +
  • instance: {
  • /**@lends patio.sql.JoinUsingClause.prototype*/
  • /**
  • @@ -11943,7 +11943,7 @@
  • * @param using the column/s to use when joining.
  • * @property using <b>READ ONLY</b> the column/s to use when joining.
  • */
  • -
  • constructor:function (using, joinType, table, tableAlias) {
  • +
  • constructor: function (using, joinType, table, tableAlias) {
  • 8 this.__using = using.map(function (u) {
  • 9 return isString(u) ? new Identifier(u) : u;
  • });
  • @@ -11958,15 +11958,15 @@
  • *
  • * @return String the SQL version of the {@link patio.sql.JoinUsingClause}.
  • */
  • -
  • toString:function (ds) {
  • +
  • toString: function (ds) {
  • 102 !Dataset && (Dataset = require("./dataset"));
  • 102 ds = ds || new Dataset();
  • 102 return ds.joinUsingClauseSql(this);
  • },
  • /**@ignore*/
  • -
  • getters:{
  • -
  • using:function () {
  • +
  • getters: {
  • +
  • using: function () {
  • 102 return this.__using;
  • }
  • }
  • @@ -11975,7 +11975,7 @@
  • 1var PlaceHolderLiteralString = define(GenericExpression, {
  • -
  • instance:{
  • +
  • instance: {
  • /**@lends patio.sql.PlaceHolderLiteralString.prototype*/
  • /**
  • @@ -11997,12 +11997,12 @@
  • * replaced in the string.
  • * @property {String} parens <b>READ ONLY</b> set to true to wrap the string in parens.
  • */
  • -
  • constructor:function (str, args, parens) {
  • -
  • 53 parens = parens || false;
  • -
  • 53 var v;
  • -
  • 53 this.__str = str;
  • -
  • 53 this.__args = isArray(args) && args.length == 1 && isHash((v = args[0])) ? v : args;
  • -
  • 53 this.__parens = parens;
  • +
  • constructor: function (str, args, parens) {
  • +
  • 55 parens = parens || false;
  • +
  • 55 var v;
  • +
  • 55 this.__str = str;
  • +
  • 55 this.__args = isArray(args) && args.length == 1 && isHash((v = args[0])) ? v : args;
  • +
  • 55 this.__parens = parens;
  • },
  • /**
  • @@ -12013,23 +12013,23 @@
  • *
  • * @return String the SQL version of the {@link patio.sql.PlaceHolderLiteralString}.
  • */
  • -
  • toString:function (ds) {
  • -
  • 53 !Dataset && (Dataset = require("./dataset"));
  • -
  • 53 ds = ds || new Dataset();
  • -
  • 53 return ds.placeholderLiteralStringSql(this);
  • +
  • toString: function (ds) {
  • +
  • 55 !Dataset && (Dataset = require("./dataset"));
  • +
  • 55 ds = ds || new Dataset();
  • +
  • 55 return ds.placeholderLiteralStringSql(this);
  • },
  • /**@ignore*/
  • -
  • getters:{
  • -
  • str:function () {
  • -
  • 56 return this.__str;
  • +
  • getters: {
  • +
  • str: function () {
  • +
  • 58 return this.__str;
  • },
  • -
  • args:function () {
  • -
  • 56 return this.__args;
  • +
  • args: function () {
  • +
  • 58 return this.__args;
  • },
  • -
  • parens:function () {
  • -
  • 56 return this.__parens;
  • +
  • parens: function () {
  • +
  • 58 return this.__parens;
  • }
  • }
  • @@ -12038,7 +12038,7 @@
  • 1var SQLFunction = define(GenericExpression, {
  • -
  • instance:{
  • +
  • instance: {
  • /**@lends patio.sql.SQLFunction.prototype*/
  • /**
  • @@ -12055,10 +12055,10 @@
  • * @property {Array} args <b>READ ONLY</b> args arguments will be literalized through
  • * {@link patio.Dataset#literal} and placed into the SQL function call.
  • * */
  • -
  • constructor:function (f) {
  • -
  • 979 var args = argsToArray(arguments).slice(1);
  • -
  • 979 this.__f = isInstanceOf(f, Identifier) ? f.value : f, this.__args = args.map(function (a) {
  • -
  • 684 return isString(a) ? sql.stringToIdentifier(a) : a;
  • +
  • constructor: function (f) {
  • +
  • 1339 var args = argsToArray(arguments).slice(1);
  • +
  • 1339 this.__f = isInstanceOf(f, Identifier) ? f.value : f, this.__args = args.map(function (a) {
  • +
  • 972 return isString(a) ? sql.stringToIdentifier(a) : a;
  • });
  • },
  • @@ -12070,20 +12070,20 @@
  • *
  • * @return String the SQL version of the {@link patio.sql.SQLFunction}.
  • */
  • -
  • toString:function (ds) {
  • -
  • 500 !Dataset && (Dataset = require("./dataset"));
  • -
  • 500 ds = ds || new Dataset();
  • -
  • 500 return ds.functionSql(this);
  • +
  • toString: function (ds) {
  • +
  • 680 !Dataset && (Dataset = require("./dataset"));
  • +
  • 680 ds = ds || new Dataset();
  • +
  • 680 return ds.functionSql(this);
  • },
  • /**@ignore*/
  • -
  • getters:{
  • -
  • f:function () {
  • -
  • 502 return this.__f;
  • +
  • getters: {
  • +
  • f: function () {
  • +
  • 682 return this.__f;
  • },
  • -
  • args:function () {
  • -
  • 502 return this.__args;
  • +
  • args: function () {
  • +
  • 682 return this.__args;
  • }
  • }
  • }
  • @@ -12104,7 +12104,7 @@
  • 1var OrderedExpression = define(Expression, {
  • -
  • instance:{
  • +
  • instance: {
  • /**@lends patio.sql.OrderedExpression.prototype*/
  • /**
  • @@ -12126,7 +12126,7 @@
  • * @property {String} [nulls=null] if value is "first" the null values will be first, if "last" then null values
  • * will be last
  • */
  • -
  • constructor:function (expression, descending, opts) {
  • +
  • constructor: function (expression, descending, opts) {
  • 92 descending = isBoolean(descending) ? descending : true;
  • 92 opts = opts || {};
  • 92 this.__expression = expression;
  • @@ -12138,22 +12138,22 @@
  • /**
  • * @return {patio.sql.OrderedExpression} a copy that is ordered ASC
  • */
  • -
  • asc:function () {
  • -
  • 0 return new OrderedExpression(this.__expression, false, {nulls:this.__nulls});
  • +
  • asc: function () {
  • +
  • 0 return new OrderedExpression(this.__expression, false, {nulls: this.__nulls});
  • },
  • /**
  • * @return {patio.sql.OrderedExpression} Return a copy that is ordered DESC
  • */
  • -
  • desc:function () {
  • -
  • 0 return new OrderedExpression(this.__expression, true, {nulls:this.__nulls});
  • +
  • desc: function () {
  • +
  • 0 return new OrderedExpression(this.__expression, true, {nulls: this.__nulls});
  • },
  • /**
  • * * @return {patio.sql.OrderedExpression} an inverted expression, changing ASC to DESC and NULLS FIRST to NULLS LAST.
  • * */
  • -
  • invert:function () {
  • -
  • 17 return new OrderedExpression(this.__expression, !this.__descending, {nulls:this._static.INVERT_NULLS[this.__nulls] || this.__nulls});
  • +
  • invert: function () {
  • +
  • 17 return new OrderedExpression(this.__expression, !this.__descending, {nulls: this._static.INVERT_NULLS[this.__nulls] || this.__nulls});
  • },
  • /**
  • @@ -12164,38 +12164,38 @@
  • *
  • * @return String the SQL version of the {@link patio.sql.OrderedExpression}.
  • */
  • -
  • toString:function (ds) {
  • +
  • toString: function (ds) {
  • 73 !Dataset && (Dataset = require("./dataset"));
  • 73 ds = ds || new Dataset();
  • 73 return ds.orderedExpressionSql(this);
  • },
  • /**@ignore*/
  • -
  • getters:{
  • -
  • expression:function () {
  • +
  • getters: {
  • +
  • expression: function () {
  • 75 return this.__expression;
  • },
  • -
  • descending:function () {
  • +
  • descending: function () {
  • 75 return this.__descending;
  • },
  • -
  • nulls:function () {
  • +
  • nulls: function () {
  • 82 return this.__nulls;
  • }
  • }
  • },
  • -
  • static:{
  • +
  • static: {
  • /**@lends patio.sql.OrderedExpression*/
  • /**
  • * Hash that contains the inversions for "first" and "last".
  • * @type Object
  • * @default {first:"last", last:"first"}
  • */
  • -
  • INVERT_NULLS:{first:"last", last:"first"}
  • +
  • INVERT_NULLS: {first: "last", last: "first"}
  • }
  • }).as(sql, "OrderedExpression");
  • 1var QualifiedIdentifier = define([GenericExpression, QualifyingMethods], {
  • -
  • instance:{
  • +
  • instance: {
  • /**@lends patio.sql.QualifiedIdentifier.prototype*/
  • /**
  • @@ -12211,9 +12211,9 @@
  • * @property table <b>READ ONLY</b> the table or schema to qualify the column or table to.
  • * @property column <b>READ ONLY</b> he column or table to qualify.
  • */
  • -
  • constructor:function (table, column) {
  • -
  • 3433 this.__table = table;
  • -
  • 3433 this.__column = column;
  • +
  • constructor: function (table, column) {
  • +
  • 4405 this.__table = table;
  • +
  • 4405 this.__column = column;
  • },
  • /**
  • @@ -12224,20 +12224,20 @@
  • *
  • * @return String the SQL version of the {@link patio.sql.QualifiedIdentifier}.
  • */
  • -
  • toString:function (ds) {
  • -
  • 3514 !Dataset && (Dataset = require("./dataset"));
  • -
  • 3514 ds = ds || new Dataset();
  • -
  • 3514 return ds.qualifiedIdentifierSql(this);
  • +
  • toString: function (ds) {
  • +
  • 4486 !Dataset && (Dataset = require("./dataset"));
  • +
  • 4486 ds = ds || new Dataset();
  • +
  • 4486 return ds.qualifiedIdentifierSql(this);
  • },
  • /**@ignore*/
  • -
  • getters:{
  • -
  • table:function () {
  • -
  • 3536 return this.__table;
  • +
  • getters: {
  • +
  • table: function () {
  • +
  • 4508 return this.__table;
  • },
  • -
  • column:function () {
  • -
  • 3541 return this.__column;
  • +
  • column: function () {
  • +
  • 4513 return this.__column;
  • }
  • }
  • }
  • @@ -12245,13 +12245,13 @@
  • 1var likeElement = function (re) {
  • -
  • 795 var ret;
  • -
  • 795 if (isRegExp(re)) {
  • -
  • 72 ret = [("" + re).replace(/^\/|\/$|\/[i|m|g]*$/g, ""), true, re.ignoreCase]
  • +
  • 867 var ret;
  • +
  • 867 if (isRegExp(re)) {
  • +
  • 108 ret = [("" + re).replace(/^\/|\/$|\/[i|m|g]*$/g, ""), true, re.ignoreCase]
  • } else {
  • -
  • 723 ret = [re, false, false];
  • +
  • 759 ret = [re, false, false];
  • }
  • -
  • 795 return ret;
  • +
  • 867 return ret;
  • };
  • /**
  • * @class Subclass of {@link patio.sql.ComplexExpression} where the expression results
  • @@ -12266,7 +12266,7 @@
  • * @memberOf patio.sql
  • */
  • 1var StringExpression = define([ComplexExpression, StringMethods, StringConcatenationMethods, InequalityMethods, NoBooleanInputMethods], {
  • -
  • static:{
  • +
  • static: {
  • /**@lends patio.sql.StringExpression*/
  • /**
  • @@ -12294,20 +12294,20 @@
  • * StringExpression.like(sql.a, 'a%', {caseInsensitive : true}) //=> "a" ILIKE 'a%'
  • * StringExpression.like(sql.a, 'a%', /^a/i) //=> "a" LIKE 'a%' OR "a" ~* '^a'
  • */
  • -
  • like:function (l) {
  • -
  • 397 var args = argsToArray(arguments, 1);
  • -
  • 397 var params = likeElement(l);
  • -
  • 397 var likeMap = this.likeMap;
  • -
  • 397 var lh = params[0], lre = params[1], lci = params[2];
  • -
  • 397 var last = args[args.length - 1];
  • -
  • 397 lci = (isHash(last) ? args.pop() : {})["caseInsensitive"] ? true : lci;
  • -
  • 397 args = args.map(function (ce) {
  • -
  • 398 var r, rre, rci;
  • -
  • 398 var ceArr = likeElement(ce);
  • -
  • 398 r = ceArr[0], rre = ceArr[1], rci = ceArr[2];
  • -
  • 398 return new BooleanExpression(likeMap["" + (lre || rre) + (lci || rci)], l, r)
  • +
  • like: function (l) {
  • +
  • 433 var args = argsToArray(arguments, 1);
  • +
  • 433 var params = likeElement(l);
  • +
  • 433 var likeMap = this.likeMap;
  • +
  • 433 var lh = params[0], lre = params[1], lci = params[2];
  • +
  • 433 var last = args[args.length - 1];
  • +
  • 433 lci = (isHash(last) ? args.pop() : {})["caseInsensitive"] ? true : lci;
  • +
  • 433 args = args.map(function (ce) {
  • +
  • 434 var r, rre, rci;
  • +
  • 434 var ceArr = likeElement(ce);
  • +
  • 434 r = ceArr[0], rre = ceArr[1], rci = ceArr[2];
  • +
  • 434 return new BooleanExpression(likeMap["" + (lre || rre) + (lci || rci)], l, r)
  • }, this);
  • -
  • 397 return args.length == 1 ? args[0] : BooleanExpression.fromArgs(["OR"].concat(args));
  • +
  • 433 return args.length == 1 ? args[0] : BooleanExpression.fromArgs(["OR"].concat(args));
  • },
  • /**
  • @@ -12315,14 +12315,14 @@
  • * LIKE expression.
  • * @type Object
  • */
  • -
  • likeMap:{"truetrue":'~*', "truefalse":"~", "falsetrue":"ILIKE", "falsefalse":"LIKE"}
  • +
  • likeMap: {"truetrue": '~*', "truefalse": "~", "falsetrue": "ILIKE", "falsefalse": "LIKE"}
  • }
  • }).as(sql, "StringExpression");
  • 1var SubScript = define(GenericExpression, {
  • -
  • instance:{
  • +
  • instance: {
  • /**@lends patio.sql.SubScript.prototype*/
  • /**
  • @@ -12333,7 +12333,7 @@
  • * @param arrCol the SQL array column
  • * @param sub The array of subscripts to use (should be an array of numbers)
  • */
  • -
  • constructor:function (arrCol, sub) {
  • +
  • constructor: function (arrCol, sub) {
  • //The SQL array column
  • 65 this.__arrCol = arrCol;
  • //The array of subscripts to use (should be an array of numbers)
  • @@ -12344,7 +12344,7 @@
  • * Create a new {@link patio.sql.Subscript} appending the given subscript(s)
  • * the the current array of subscripts.
  • */
  • -
  • addSub:function (sub) {
  • +
  • addSub: function (sub) {
  • 0 return new SubScript(this.__arrCol, this.__sub.concat(sub));
  • },
  • @@ -12356,19 +12356,19 @@
  • *
  • * @return String the SQL version of the {@link patio.sql.SubScript}.
  • */
  • -
  • toString:function (ds) {
  • +
  • toString: function (ds) {
  • 65 !Dataset && (Dataset = require("./dataset"));
  • 65 ds = ds || new Dataset();
  • 65 return ds.subscriptSql(this);
  • },
  • /**@ignore*/
  • -
  • getters:{
  • -
  • f:function () {
  • +
  • getters: {
  • +
  • f: function () {
  • 66 return this.__arrCol;
  • },
  • -
  • sub:function () {
  • +
  • sub: function () {
  • 66 return this.__sub;
  • }
  • }
  • @@ -12382,12 +12382,12 @@
  • 1var addStringMethod = function (op) {
  • 24 return function () {
  • -
  • 3615 return this.__str[op].apply(this.__str, arguments);
  • +
  • 3760 return this.__str[op].apply(this.__str, arguments);
  • }
  • };
  • 1var LiteralString = define([OrderedMethods, ComplexExpressionMethods, BooleanMethods, NumericMethods, StringMethods, InequalityMethods, AliasMethods], {
  • -
  • instance:{
  • +
  • instance: {
  • /**@lends patio.sql.LiteralString*/
  • /**
  • @@ -12404,8 +12404,8 @@
  • *
  • * @param {String} str the literal string.
  • */
  • -
  • constructor:function (str) {
  • -
  • 3107 this.__str = str;
  • +
  • constructor: function (str) {
  • +
  • 572 this.__str = str;
  • }
  • }
  • }).as(sql, "LiteralString");
  • @@ -12438,10 +12438,10 @@
    - Coverage91.90 - SLOC1029 - LOC284 - Missed23 + Coverage91.43 + SLOC1023 + LOC280 + Missed24
    @@ -12730,7 +12730,6 @@
  • 108 if (!isFunction(this.schemaParseTable)) {
  • 0 throw new Error("Schema parsing is not implemented on this database");
  • }
  • -
  • 108 var ret = new Promise();
  • 108 opts = opts || {};
  • 108 var schemaParts = this.__schemaAndTable(table);
  • 108 var sch = schemaParts[0], tableName = schemaParts[1];
  • @@ -12739,26 +12738,21 @@
  • 108 if (opts.reload) {
  • 1 delete this.schemas[quotedName];
  • }
  • -
  • 108 if (this.schemas[quotedName]) {
  • -
  • 38 ret = this.schemas[quotedName];
  • -
  • } else {
  • -
  • 70 var self = this;
  • -
  • 70 ret = this.schemas[quotedName] = this.schemaParseTable(tableName, opts).chain(function (cols) {
  • -
  • 70 if (!cols || cols.length === 0) {
  • -
  • 0 throw new Error("Error parsing schema, " + table + " no columns returns, table probably doesnt exist")
  • -
  • } else {
  • -
  • 70 var schema = {};
  • -
  • 70 cols.forEach(function (c) {
  • -
  • 367 var name = c[0];
  • -
  • 367 c = c[1];
  • -
  • 367 c.jsDefault = self.__columnSchemaToJsDefault(c["default"], c.type);
  • -
  • 367 schema[name] = c;
  • -
  • });
  • -
  • 70 return schema;
  • -
  • }
  • -
  • });
  • -
  • }
  • -
  • 108 return ret.promise();
  • +
  • 108 var self = this;
  • +
  • 108 return this.schemaParseTable(tableName, opts).chain(function (cols) {
  • +
  • 108 if (!cols || cols.length === 0) {
  • +
  • 0 throw new Error("Error parsing schema, " + table + " no columns returns, table probably doesnt exist")
  • +
  • } else {
  • +
  • 108 var schema = {};
  • +
  • 108 cols.forEach(function (c) {
  • +
  • 794 var name = c[0];
  • +
  • 794 c = c[1];
  • +
  • 794 c.jsDefault = self.__columnSchemaToJsDefault(c["default"], c.type);
  • +
  • 794 schema[name] = c;
  • +
  • });
  • +
  • 108 return schema;
  • +
  • }
  • +
  • });
  • },
  • /**
  • @@ -12772,7 +12766,7 @@
  • */
  • removeCachedSchema: function (table) {
  • 482 if (this.schemas && !isEmpty(this.schemas)) {
  • -
  • 192 delete this.schemas[this.__quoteSchemaTable(table)];
  • +
  • 0 delete this.schemas[this.__quoteSchemaTable(table)];
  • }
  • },
  • @@ -13023,12 +13017,12 @@
  • },
  • _getConnection: function () {
  • -
  • 2253 return this.pool.getConnection();
  • +
  • 2291 return this.pool.getConnection();
  • },
  • _returnConnection: function (conn) {
  • -
  • 5131 if (!this.alreadyInTransaction(conn)) {
  • -
  • 1353 this.pool.returnConnection(conn);
  • +
  • 5169 if (!this.alreadyInTransaction(conn)) {
  • +
  • 1391 this.pool.returnConnection(conn);
  • }
  • },
  • @@ -13231,19 +13225,19 @@
  • //Convert the given default, which should be a database specific string, into
  • //a javascript object.
  • __columnSchemaToJsDefault: function (def, type) {
  • -
  • 419 if (isNull(def) || isUndefined(def)) {
  • -
  • 310 return null;
  • +
  • 846 if (isNull(def) || isUndefined(def)) {
  • +
  • 701 return null;
  • }
  • -
  • 109 var origDefault = def, m, datePattern, dateTimePattern, timeStampPattern, timePattern;
  • -
  • 109 if (this.type === "postgres" && (m = def.match(this.POSTGRES_DEFAULT_RE)) !== null) {
  • +
  • 145 var origDefault = def, m, datePattern, dateTimePattern, timeStampPattern, timePattern;
  • +
  • 145 if (this.type === "postgres" && (m = def.match(this.POSTGRES_DEFAULT_RE)) !== null) {
  • 9 def = m[1] || m[2];
  • 9 dateTimePattern = this.POSTGRES_DATE_TIME_PATTERN;
  • 9 timePattern = this.POSTGRES_TIME_PATTERN;
  • }
  • -
  • 109 if (this.type === "mssql" && (m = def.match(this.MSSQL_DEFAULT_RE)) !== null) {
  • +
  • 145 if (this.type === "mssql" && (m = def.match(this.MSSQL_DEFAULT_RE)) !== null) {
  • 4 def = m[1] || m[2];
  • }
  • -
  • 109 if (["string", "blob", "date", "datetime", "year", "timestamp", "time", "enum"].indexOf(type) !== -1) {
  • +
  • 145 if (["string", "blob", "date", "datetime", "year", "timestamp", "time", "enum"].indexOf(type) !== -1) {
  • 32 if (this.type === "mysql") {
  • 12 if (["date", "datetime", "time", "timestamp"].indexOf(type) !== -1 && def.match(this.MYSQL_TIMESTAMP_RE)) {
  • 4 return null;
  • @@ -13255,9 +13249,9 @@
  • }
  • 26 def = m[1].replace("''", "'");
  • }
  • -
  • 103 var ret = null;
  • -
  • 103 try {
  • -
  • 103 switch (type) {
  • +
  • 139 var ret = null;
  • +
  • 139 try {
  • +
  • 139 switch (type) {
  • case "boolean":
  • 6 if (def.match(/[f0]/i)) {
  • 3 ret = false;
  • @@ -13276,11 +13270,11 @@
  • 13 ret = def;
  • 13 break;
  • case "integer":
  • -
  • 57 ret = parseInt(def, 10);
  • -
  • 57 if (isNaN(ret)) {
  • -
  • 50 ret = null;
  • +
  • 92 ret = parseInt(def, 10);
  • +
  • 92 if (isNaN(ret)) {
  • +
  • 85 ret = null;
  • }
  • -
  • 57 break;
  • +
  • 92 break;
  • case "float":
  • case "decimal":
  • 11 ret = parseFloat(def, 10);
  • @@ -13306,7 +13300,7 @@
  • }
  • } catch (e) {
  • }
  • -
  • 103 return ret;
  • +
  • 139 return ret;
  • },
  • /**
  • @@ -13316,37 +13310,37 @@
  • * @private
  • */
  • schemaColumnType: function (dbType) {
  • -
  • 366 var ret = dbType, m;
  • -
  • 366 if (dbType.match(/^interval$/i)) {
  • +
  • 793 var ret = dbType, m;
  • +
  • 793 if (dbType.match(/^interval$/i)) {
  • 0 ret = "interval";
  • -
  • 366 } else if (dbType.match(/^(character( varying)?|n?(var)?char)/i)) {
  • -
  • 178 ret = "string";
  • -
  • 188 } else if (dbType.match(/^int(eger)?|(big|small|tiny)int/i)) {
  • -
  • 115 ret = "integer";
  • -
  • 73 } else if (dbType.match(/^date$/i)) {
  • -
  • 1 ret = "date";
  • -
  • 72 } else if (dbType.match(/^year/i)) {
  • +
  • 793 } else if (dbType.match(/^(character( varying)?|n?(var)?char)/i)) {
  • +
  • 191 ret = "string";
  • +
  • 602 } else if (dbType.match(/^int(eger)?|(big|small|tiny)int/i)) {
  • +
  • 156 ret = "integer";
  • +
  • 446 } else if (dbType.match(/^date$/i)) {
  • +
  • 34 ret = "date";
  • +
  • 412 } else if (dbType.match(/^year/i)) {
  • 0 ret = "year";
  • -
  • 72 } else if (dbType.match(/^((small)?datetime|timestamp( with(out)? time zone)?)$/i)) {
  • +
  • 412 } else if (dbType.match(/^((small)?datetime|timestamp( with(out)? time zone)?)$/i)) {
  • 8 ret = "datetime";
  • -
  • 64 } else if (dbType.match(/^time( with(out)? timezone)?$/i)) {
  • +
  • 404 } else if (dbType.match(/^time( with(out)? timezone)?$/i)) {
  • 0 ret = "time";
  • -
  • 64 } else if (dbType.match(/^(bit|boolean)$/i)) {
  • +
  • 404 } else if (dbType.match(/^(bit|boolean)$/i)) {
  • 0 ret = "boolean";
  • -
  • 64 } else if (dbType.match(/^(real|float|double( precision)?)$/i)) {
  • +
  • 404 } else if (dbType.match(/^(real|float|double( precision)?)$/i)) {
  • 12 ret = "float";
  • -
  • 52 } else if ((m = dbType.match(/^(?:(?:(?:num(?:ber|eric)?|decimal|double)(?:\(\d+,\s*(\d+)\))?)|(?:small)?money)/i))) {
  • -
  • 2 ret = m[1] && m[1] === '0' ? "integer" : "decimal";
  • -
  • 50 } else if (dbType.match(/n?text/i)) {
  • -
  • 37 ret = "text";
  • -
  • 13 } else if (dbType.match(/bytea|[bc]lob|image|(var)?binary/i)) {
  • -
  • 12 ret = "blob";
  • -
  • 1 } else if (dbType.match(/^enum/i)) {
  • -
  • 1 ret = "enum";
  • +
  • 392 } else if ((m = dbType.match(/^(?:(?:(?:num(?:ber|eric)?|decimal|double)(?:\(\d+,\s*(\d+)\))?)|(?:small)?money)/i))) {
  • +
  • 68 ret = m[1] && m[1] === '0' ? "integer" : "decimal";
  • +
  • 324 } else if (dbType.match(/n?text/i)) {
  • +
  • 305 ret = "text";
  • +
  • 19 } else if (dbType.match(/bytea|[bc]lob|image|(var)?binary/i)) {
  • +
  • 17 ret = "blob";
  • +
  • 2 } else if (dbType.match(/^enum/i)) {
  • +
  • 2 ret = "enum";
  • 0 } else if (dbType.match(/^set/i)) {
  • 0 ret = "set";
  • }
  • -
  • 366 return ret;
  • +
  • 793 return ret;
  • },
  • /**
  • @@ -13356,8 +13350,8 @@
  • * @return {Boolean} true if this dabase is currently in a transaction.
  • */
  • alreadyInTransaction: function (conn, opts) {
  • -
  • 6040 opts = opts || {};
  • -
  • 6040 return this.__transactions.indexOf(conn) !== -1 && (!this.supportsSavepoints || !opts.savepoint);
  • +
  • 6078 opts = opts || {};
  • +
  • 6078 return this.__transactions.indexOf(conn) !== -1 && (!this.supportsSavepoints || !opts.savepoint);
  • },
  • /**@ignore*/
  • @@ -13403,9 +13397,9 @@
  • * @type Function
  • */
  • outputIdentifierFunc: function () {
  • -
  • 73 var ds = this.dataset;
  • -
  • 73 return function (ident) {
  • -
  • 577 return ds.outputIdentifier(ident);
  • +
  • 111 var ds = this.dataset;
  • +
  • 111 return function (ident) {
  • +
  • 1040 return ds.outputIdentifier(ident);
  • };
  • },
  • @@ -13418,9 +13412,9 @@
  • * @type Function
  • */
  • inputIdentifierFunc: function () {
  • -
  • 132 var ds = this.dataset;
  • -
  • 132 return function (ident) {
  • -
  • 132 return ds.inputIdentifier(ident);
  • +
  • 170 var ds = this.dataset;
  • +
  • 170 return function (ident) {
  • +
  • 170 return ds.inputIdentifier(ident);
  • };
  • },
  • @@ -13433,8 +13427,8 @@
  • * @type patio.Dataset
  • */
  • metadataDataset: function () {
  • -
  • 73 if (this.__metadataDataset) {
  • -
  • 42 return this.__metadataDataset;
  • +
  • 111 if (this.__metadataDataset) {
  • +
  • 80 return this.__metadataDataset;
  • }
  • 31 var ds = this.dataset;
  • 31 ds.identifierInputMethod = this.identifierInputMethod;
  • @@ -14169,9 +14163,9 @@
  • constructor:function () {
  • //We initialize these here because otherwise
  • //the will be blank because of recursive dependencies.
  • -
  • 25047 !patio && (patio = require("../index"));
  • -
  • 25047 !Dataset && (Dataset = patio.Dataset);
  • -
  • 25047 this._super(arguments);
  • +
  • 26500 !patio && (patio = require("../index"));
  • +
  • 26500 !Dataset && (Dataset = patio.Dataset);
  • +
  • 26500 this._super(arguments);
  • },
  • /**
  • @@ -14363,29 +14357,29 @@
  • *
  • */
  • qualifiedColumnName:function (column, table) {
  • -
  • 914 if (isString(column)) {
  • -
  • 911 var parts = this._splitString(column);
  • -
  • 911 var columnTable = parts[0], alias = parts[2], tableAlias;
  • -
  • 911 column = parts[1];
  • -
  • 911 if (!columnTable) {
  • -
  • 909 if (isInstanceOf(table, Identifier)) {
  • -
  • 886 table = table.value;
  • +
  • 1166 if (isString(column)) {
  • +
  • 1163 var parts = this._splitString(column);
  • +
  • 1163 var columnTable = parts[0], alias = parts[2], tableAlias;
  • +
  • 1163 column = parts[1];
  • +
  • 1163 if (!columnTable) {
  • +
  • 1161 if (isInstanceOf(table, Identifier)) {
  • +
  • 1138 table = table.value;
  • }
  • -
  • 909 if (isInstanceOf(table, AliasedExpression)) {
  • +
  • 1161 if (isInstanceOf(table, AliasedExpression)) {
  • 0 tableAlias = table.alias;
  • -
  • 909 } else if (isInstanceOf(table, QualifiedIdentifier)) {
  • +
  • 1161 } else if (isInstanceOf(table, QualifiedIdentifier)) {
  • 1 tableAlias = table;
  • } else {
  • -
  • 908 parts = this._splitString(table);
  • -
  • 908 var schema = parts[0], tableAlias = parts[2];
  • -
  • 908 table = parts[1];
  • -
  • 908 if (schema) {
  • +
  • 1160 parts = this._splitString(table);
  • +
  • 1160 var schema = parts[0], tableAlias = parts[2];
  • +
  • 1160 table = parts[1];
  • +
  • 1160 if (schema) {
  • 0 tableAlias = new Identifier(tableAlias) || new QualifiedIdentifier(schema, table);
  • }
  • }
  • -
  • 909 columnTable = tableAlias || table;
  • +
  • 1161 columnTable = tableAlias || table;
  • }
  • -
  • 911 return new QualifiedIdentifier(columnTable, column);
  • +
  • 1163 return new QualifiedIdentifier(columnTable, column);
  • 3 } else if (isInstanceOf(column, Identifier)) {
  • 0 return column.qualify(table);
  • } else {
  • @@ -14456,36 +14450,36 @@
  • * @return {String} a literal representation of the value.
  • */
  • literal:function (v) {
  • -
  • 38421 if (isInstanceOf(v, LiteralString)) {
  • +
  • 41173 if (isInstanceOf(v, LiteralString)) {
  • 193 return "" + v;
  • -
  • 38228 } else if (isString(v)) {
  • -
  • 5393 return this._literalString(v);
  • -
  • 32835 } else if (isNumber(v)) {
  • -
  • 6145 return this._literalNumber(v);
  • +
  • 40980 } else if (isString(v)) {
  • +
  • 5467 return this._literalString(v);
  • +
  • 35513 } else if (isNumber(v)) {
  • +
  • 6182 return this._literalNumber(v);
  • }
  • -
  • 26690 else if (isInstanceOf(v, Expression)) {
  • -
  • 24419 return this._literalExpression(v);
  • +
  • 29331 else if (isInstanceOf(v, Expression)) {
  • +
  • 26844 return this._literalExpression(v);
  • }
  • -
  • 2271 else if (isInstanceOf(v, Dataset)) {
  • +
  • 2487 else if (isInstanceOf(v, Dataset)) {
  • 104 return this._literalDataset(v);
  • }
  • -
  • 2167 else if (isArray(v)) {
  • -
  • 1808 return this._literalArray(v);
  • -
  • 359 } else if (isInstanceOf(v, sql.Year)) {
  • +
  • 2383 else if (isArray(v)) {
  • +
  • 1988 return this._literalArray(v);
  • +
  • 395 } else if (isInstanceOf(v, sql.Year)) {
  • 1 return this._literalYear(v);
  • -
  • 358 } else if (isInstanceOf(v, sql.TimeStamp, sql.DateTime)) {
  • +
  • 394 } else if (isInstanceOf(v, sql.TimeStamp, sql.DateTime)) {
  • 31 return this._literalTimestamp(v);
  • -
  • 327 } else if (isDate(v)) {
  • +
  • 363 } else if (isDate(v)) {
  • 7 return this._literalDate(v);
  • -
  • 320 } else if (isInstanceOf(v, sql.Time)) {
  • +
  • 356 } else if (isInstanceOf(v, sql.Time)) {
  • 1 return this._literalTime(v);
  • -
  • 319 } else if (Buffer.isBuffer(v)) {
  • +
  • 355 } else if (Buffer.isBuffer(v)) {
  • 11 return this._literalBuffer(v);
  • -
  • 308 } else if (isNull(v)) {
  • +
  • 344 } else if (isNull(v)) {
  • 227 return this._literalNull();
  • }
  • -
  • 81 else if (isBoolean(v)) {
  • -
  • 71 return this._literalBoolean(v);
  • +
  • 117 else if (isBoolean(v)) {
  • +
  • 107 return this._literalBoolean(v);
  • }
  • 10 else if (isHash(v)) {
  • 6 return this._literalObject(v);
  • @@ -14655,22 +14649,22 @@
  • //Prepares an SQL statement by calling all clause methods for the given statement type.
  • _clauseSql:function (type) {
  • -
  • 5786 var sql = [("" + type).toUpperCase()];
  • -
  • 5786 try {
  • -
  • 5786 this._static[sql + "_CLAUSE_METHODS"].forEach(function (m) {
  • -
  • 58169 if (m.match("With")) {
  • -
  • 5509 this[m](sql);
  • +
  • 5823 var sql = [("" + type).toUpperCase()];
  • +
  • 5823 try {
  • +
  • 5823 this._static[sql + "_CLAUSE_METHODS"].forEach(function (m) {
  • +
  • 58650 if (m.match("With")) {
  • +
  • 5546 this[m](sql);
  • } else {
  • -
  • 52660 var sqlRet = this[m]();
  • -
  • 52658 if (sqlRet) {
  • -
  • 18637 sql.push(sqlRet);
  • +
  • 53104 var sqlRet = this[m]();
  • +
  • 53102 if (sqlRet) {
  • +
  • 18820 sql.push(sqlRet);
  • }
  • }
  • }, this);
  • } catch (e) {
  • 2 throw e;
  • }
  • -
  • 5784 return sql.join("");
  • +
  • 5821 return sql.join("");
  • },
  • @@ -14708,7 +14702,7 @@
  • //SQL fragment for Array
  • _arraySql:function (a) {
  • -
  • 1809 return !a.length ? '(NULL)' : "(" + this.__expressionList(a) + ")";
  • +
  • 1989 return !a.length ? '(NULL)' : "(" + this.__expressionList(a) + ")";
  • },
  • //This method quotes the given name with the SQL standard double quote.
  • @@ -14730,7 +14724,7 @@
  • * SQL fragment for AliasedExpression
  • */
  • aliasedExpressionSql:function (ae) {
  • -
  • 767 return this.__asSql(this.literal(ae.expression), ae.alias);
  • +
  • 947 return this.__asSql(this.literal(ae.expression), ae.alias);
  • },
  • /**
  • @@ -14784,16 +14778,16 @@
  • * SQL fragment for complex expressions
  • **/
  • complexExpressionSql:function (op, args) {
  • -
  • 5651 var newOp;
  • -
  • 5651 var isOperators = this._static.IS_OPERATORS, isLiterals = this._static.IS_LITERALS;
  • -
  • 5651 if ((newOp = isOperators[op]) != null) {
  • -
  • 232 var r = args[1], v = isNull(r) ? isLiterals.NULL : isLiterals[r];
  • -
  • 232 if (r == null || this.supportsIsTrue) {
  • -
  • 232 if (isUndefined(v)) {
  • +
  • 6196 var newOp;
  • +
  • 6196 var isOperators = this._static.IS_OPERATORS, isLiterals = this._static.IS_LITERALS;
  • +
  • 6196 if ((newOp = isOperators[op]) != null) {
  • +
  • 304 var r = args[1], v = isNull(r) ? isLiterals.NULL : isLiterals[r];
  • +
  • 304 if (r == null || this.supportsIsTrue) {
  • +
  • 304 if (isUndefined(v)) {
  • 0 throw new QueryError(string.format("Invalid argument('%s') used for IS operator", r));
  • }
  • -
  • 232 l = args[0];
  • -
  • 232 return string.format("(%s %s %s)", isString(l) ? l : this.literal(l), newOp, v);
  • +
  • 304 l = args[0];
  • +
  • 304 return string.format("(%s %s %s)", isString(l) ? l : this.literal(l), newOp, v);
  • 0 } else if (op == "IS") {
  • 0 return this.complexExpressionSql("EQ", args);
  • } else {
  • @@ -14802,7 +14796,7 @@
  • null)]);
  • }
  • -
  • 5419 } else if (["IN", "NOTIN"].indexOf(op) != -1) {
  • +
  • 5892 } else if (["IN", "NOTIN"].indexOf(op) != -1) {
  • 17 var cols = args[0], vals = args[1], colArray = isArray(cols), valArray = false, emptyValArray = false;
  • 17 if (isArray(vals)) {
  • @@ -14848,12 +14842,12 @@
  • ComplexExpression.IN_OPERATORS[op], this.literal(vals));
  • }
  • }
  • -
  • 5402 } else if ((newOp = this._static.TWO_ARITY_OPERATORS[op]) != null) {
  • -
  • 4589 var l = args[0];
  • -
  • 4589 return format("(%s %s %s)", isString(l) ? l : this.literal(l), newOp,
  • +
  • 5875 } else if ((newOp = this._static.TWO_ARITY_OPERATORS[op]) != null) {
  • +
  • 4952 var l = args[0];
  • +
  • 4952 return format("(%s %s %s)", isString(l) ? l : this.literal(l), newOp,
  • this.literal(args[1]));
  • -
  • 813 } else if ((newOp = this._static.N_ARITY_OPERATORS[op]) != null) {
  • -
  • 779 return string.format("(%s)", args.map(this.literal, this).join(" " + newOp + " "));
  • +
  • 923 } else if ((newOp = this._static.N_ARITY_OPERATORS[op]) != null) {
  • +
  • 889 return string.format("(%s)", args.map(this.literal, this).join(" " + newOp + " "));
  • 34 } else if (op == "NOT") {
  • 5 return string.format("NOT %s", this.literal(args[0]));
  • 29 } else if (op == "NOOP") {
  • @@ -14878,8 +14872,8 @@
  • * SQL fragment specifying an SQL function call
  • * */
  • functionSql:function (f) {
  • -
  • 500 var args = f.args
  • -
  • 500 return string.format("%s%s", f.f, args.length == 0 ? '()' : this.literal(args));
  • +
  • 680 var args = f.args
  • +
  • 680 return string.format("%s%s", f.f, args.length == 0 ? '()' : this.literal(args));
  • },
  • /**
  • @@ -14887,13 +14881,13 @@
  • * SQL fragment specifying a JOIN clause without ON or USING.
  • * */
  • joinClauseSql:function (jc) {
  • -
  • 771 var table = jc.table
  • -
  • 771 var tableAlias = jc.tableAlias
  • -
  • 771 if (table === tableAlias) {
  • +
  • 951 var table = jc.table
  • +
  • 951 var tableAlias = jc.tableAlias
  • +
  • 951 if (table === tableAlias) {
  • 37 tableAlias = null;
  • }
  • -
  • 771 var tref = this.__tableRef(table);
  • -
  • 771 return string.format(" %s %s", this._joinTypeSql(jc.joinType),
  • +
  • 951 var tref = this.__tableRef(table);
  • +
  • 951 return string.format(" %s %s", this._joinTypeSql(jc.joinType),
  • tableAlias ? this.__asSql(tref, tableAlias) : tref);
  • },
  • @@ -14902,7 +14896,7 @@
  • * SQL fragment specifying a JOIN clause with ON.
  • **/
  • joinOnClauseSql:function (jc) {
  • -
  • 652 return string.format("%s ON %s", this.joinClauseSql(jc), this.literal(this._filterExpr(jc.on)));
  • +
  • 832 return string.format("%s ON %s", this.joinClauseSql(jc), this.literal(this._filterExpr(jc.on)));
  • },
  • /**
  • @@ -14940,23 +14934,23 @@
  • * SQL fragment for a literal string with placeholders
  • * */
  • placeholderLiteralStringSql:function (pls) {
  • -
  • 53 var args = pls.args;
  • -
  • 53 var s;
  • -
  • 53 if (isHash(args)) {
  • +
  • 55 var args = pls.args;
  • +
  • 55 var s;
  • +
  • 55 if (isHash(args)) {
  • 6 for (var i in args) {
  • 10 args[i] = this.literal(args[i]);
  • }
  • 6 s = string.format(pls.str, args);
  • } else {
  • -
  • 47 s = pls.str.replace(this._static.QUESTION_MARK, "%s");
  • -
  • 47 args = toArray(args).map(this.literal, this);
  • -
  • 47 s = string.format(s, args);
  • +
  • 49 s = pls.str.replace(this._static.QUESTION_MARK, "%s");
  • +
  • 49 args = toArray(args).map(this.literal, this);
  • +
  • 49 s = string.format(s, args);
  • }
  • -
  • 53 if (pls.parens) {
  • +
  • 55 if (pls.parens) {
  • 30 s = string.format("(%s)", s);
  • }
  • -
  • 53 return s;
  • +
  • 55 return s;
  • },
  • @@ -14966,10 +14960,10 @@
  • * a table and a column (or schema and table).
  • */
  • qualifiedIdentifierSql:function (qcr) {
  • -
  • 3514 return [qcr.table, qcr.column].map(
  • +
  • 4486 return [qcr.table, qcr.column].map(
  • function (x) {
  • -
  • 7028 return [QualifiedIdentifier, Identifier, String].some(function (c) {
  • -
  • 19837 return x instanceof c
  • +
  • 8972 return [QualifiedIdentifier, Identifier, String].some(function (c) {
  • +
  • 25525 return x instanceof c
  • }) ? this.literal(x) : this.quoteIdentifier(x)
  • }, this).join('.');
  • },
  • @@ -14982,18 +14976,18 @@
  • * quote the name with {@link patio.dataset._Sql#_quotedIdentifier}.
  • */
  • quoteIdentifier:function (name) {
  • -
  • 29072 if (isInstanceOf(name, LiteralString)) {
  • -
  • 228 return name;
  • +
  • 31226 if (isInstanceOf(name, LiteralString)) {
  • +
  • 372 return name;
  • } else {
  • -
  • 28844 if (isInstanceOf(name, Identifier)) {
  • -
  • 19519 name = name.value;
  • +
  • 30854 if (isInstanceOf(name, Identifier)) {
  • +
  • 19885 name = name.value;
  • }
  • -
  • 28844 name = this.inputIdentifier(name);
  • -
  • 28844 if (this.quoteIdentifiers) {
  • -
  • 21704 name = this._quotedIdentifier(name)
  • +
  • 30854 name = this.inputIdentifier(name);
  • +
  • 30854 if (this.quoteIdentifiers) {
  • +
  • 23791 name = this._quotedIdentifier(name)
  • }
  • }
  • -
  • 28844 return name;
  • +
  • 30854 return name;
  • },
  • /**
  • @@ -15003,9 +14997,9 @@
  • * identifierOutputMethod.
  • */
  • inputIdentifier:function (v) {
  • -
  • 28976 var i = this.__identifierInputMethod;
  • -
  • 28976 v = v.toString(this);
  • -
  • 28976 return !isUndefinedOrNull(i) ?
  • +
  • 31024 var i = this.__identifierInputMethod;
  • +
  • 31024 v = v.toString(this);
  • +
  • 31024 return !isUndefinedOrNull(i) ?
  • isFunction(v[i]) ?
  • v[i]() :
  • isFunction(comb[i]) ?
  • @@ -15021,9 +15015,9 @@
  • * identifierOutputMethod.
  • */
  • outputIdentifier:function (v) {
  • -
  • 17681 (v == '' && (v = 'untitled'));
  • -
  • 17681 var i = this.__identifierOutputMethod;
  • -
  • 17681 return !isUndefinedOrNull(i) ?
  • +
  • 18372 (v == '' && (v = 'untitled'));
  • +
  • 18372 var i = this.__identifierOutputMethod;
  • +
  • 18372 return !isUndefinedOrNull(i) ?
  • isFunction(v[i]) ?
  • v[i]() :
  • isFunction(comb[i]) ?
  • @@ -15039,10 +15033,10 @@
  • * quoted (if quoting identifiers)
  • */
  • quoteSchemaTable:function (table) {
  • -
  • 2187 var parts = this.schemaAndTable(table);
  • -
  • 2187 var schema = parts[0];
  • -
  • 2187 table = parts[1];
  • -
  • 2187 return string.format("%s%s", schema ? this.quoteIdentifier(schema) + "." : "", this.quoteIdentifier(table));
  • +
  • 1995 var parts = this.schemaAndTable(table);
  • +
  • 1995 var schema = parts[0];
  • +
  • 1995 table = parts[1];
  • +
  • 1995 return string.format("%s%s", schema ? this.quoteIdentifier(schema) + "." : "", this.quoteIdentifier(table));
  • },
  • @@ -15051,15 +15045,15 @@
  • * Split the schema information from the table
  • */
  • schemaAndTable:function (tableName) {
  • -
  • 2380 var sch = this.db ? this.db.defaultSchema || null : null;
  • -
  • 2380 if (isString(tableName)) {
  • -
  • 967 var parts = this._splitString(tableName);
  • -
  • 967 var s = parts[0], table = parts[1];
  • -
  • 967 return [s || sch, table];
  • -
  • 1413 } else if (isInstanceOf(tableName, QualifiedIdentifier)) {
  • +
  • 2188 var sch = this.db ? this.db.defaultSchema || null : null;
  • +
  • 2188 if (isString(tableName)) {
  • +
  • 776 var parts = this._splitString(tableName);
  • +
  • 776 var s = parts[0], table = parts[1];
  • +
  • 776 return [s || sch, table];
  • +
  • 1412 } else if (isInstanceOf(tableName, QualifiedIdentifier)) {
  • 3 return [tableName.table, tableName.column]
  • -
  • 1410 } else if (isInstanceOf(tableName, Identifier)) {
  • -
  • 1410 return [null, tableName.value];
  • +
  • 1409 } else if (isInstanceOf(tableName, Identifier)) {
  • +
  • 1409 return [null, tableName.value];
  • } else {
  • 0 throw new QueryError("table should be a QualifiedIdentifier, Identifier, or String");
  • }
  • @@ -15085,7 +15079,7 @@
  • * SQL fragment for specifying an alias. expression should already be literalized.
  • */
  • __asSql:function (expression, alias) {
  • -
  • 862 return string.format("%s AS %s", expression, this.quoteIdentifier(alias));
  • +
  • 1042 return string.format("%s AS %s", expression, this.quoteIdentifier(alias));
  • },
  • /**
  • @@ -15093,7 +15087,7 @@
  • * column names. If the array is empty, a wildcard (*) is returned.
  • */
  • __columnList:function (columns) {
  • -
  • 4771 return (!columns || columns.length == 0) ? this._static.WILDCARD : this.__expressionList(columns);
  • +
  • 4808 return (!columns || columns.length == 0) ? this._static.WILDCARD : this.__expressionList(columns);
  • },
  • /**
  • @@ -15108,7 +15102,7 @@
  • * expressions.
  • */
  • __expressionList:function (columns) {
  • -
  • 3948 return columns.map(this.literal, this).join(this._static.COMMA_SEPARATOR);
  • +
  • 4200 return columns.map(this.literal, this).join(this._static.COMMA_SEPARATOR);
  • },
  • //Format the timestamp based on the default_timestamp_format, with a couple
  • @@ -15124,9 +15118,9 @@
  • * and converts to uppercase/
  • */
  • _joinTypeSql:function (joinType) {
  • -
  • 768 return (joinType || "").replace(/([a-z]+)|([A-Z][a-z]+)/g,
  • +
  • 948 return (joinType || "").replace(/([a-z]+)|([A-Z][a-z]+)/g,
  • function (m) {
  • -
  • 957 return m.toUpperCase() + " ";
  • +
  • 1209 return m.toUpperCase() + " ";
  • }
  • ).trimRight() + " JOIN";
  • },
  • @@ -15170,18 +15164,18 @@
  • * @return SQL fragment for Array. Treats as an expression if an array of all two pairs, or as a SQL array otherwise.
  • */
  • _literalArray:function (v) {
  • -
  • 1808 return Expression.isConditionSpecifier(v) ? this._literalExpression(BooleanExpression.fromValuePairs(v)) : this._arraySql(v);
  • +
  • 1988 return Expression.isConditionSpecifier(v) ? this._literalExpression(BooleanExpression.fromValuePairs(v)) : this._arraySql(v);
  • },
  • /**
  • * @return SQL fragment for a number.
  • */
  • _literalNumber:function (num) {
  • -
  • 6145 var ret = "" + num;
  • -
  • 6145 if (isNaN(num) || num == Infinity) {
  • +
  • 6182 var ret = "" + num;
  • +
  • 6182 if (isNaN(num) || num == Infinity) {
  • 0 ret = string.format("'%s'", ret);
  • }
  • -
  • 6145 return ret;
  • +
  • 6182 return ret;
  • },
  • /**
  • @@ -15223,14 +15217,14 @@
  • * @return SQL fragment for a boolean.
  • */
  • _literalBoolean:function (b) {
  • -
  • 71 return b ? this._static.BOOL_TRUE : this._static.BOOL_FALSE;
  • +
  • 107 return b ? this._static.BOOL_TRUE : this._static.BOOL_FALSE;
  • },
  • /**
  • * @return SQL fragment for SQL::Expression, result depends on the specific type of expression.
  • * */
  • _literalExpression:function (v) {
  • -
  • 24429 return v.toString(this);
  • +
  • 26854 return v.toString(this);
  • },
  • /**
  • @@ -15249,10 +15243,10 @@
  • * @return SQL fragment for String. Doubles \ and ' by default.
  • * */
  • _literalString:function (v) {
  • -
  • 162 var parts = this._splitString(v);
  • -
  • 162 var table = parts[0], column = parts[1], alias = parts[2];
  • -
  • 162 if (!alias) {
  • -
  • 162 return column && table ? this._literalExpression(QualifiedIdentifier.fromArgs([table, column])) : "'"
  • +
  • 164 var parts = this._splitString(v);
  • +
  • 164 var table = parts[0], column = parts[1], alias = parts[2];
  • +
  • 164 if (!alias) {
  • +
  • 164 return column && table ? this._literalExpression(QualifiedIdentifier.fromArgs([table, column])) : "'"
  • + v.replace(/\\/g, "\\\\").replace(/'/g, "''") + "'"
  • } else {
  • 0 return this.literal(new AliasedExpression(column
  • @@ -15263,9 +15257,9 @@
  • /*SQL STATEMENT CREATION METHODS*/
  • _selectQualifySql:function () {
  • -
  • 4319 var o = this.__opts;
  • -
  • 4319 var table = this.__opts.alwaysQualify;
  • -
  • 4319 if (table && !o.sql) {
  • +
  • 4356 var o = this.__opts;
  • +
  • 4356 var table = this.__opts.alwaysQualify;
  • +
  • 4356 if (table && !o.sql) {
  • 2 array.intersect(Object.keys(o), this._static.QUALIFY_KEYS).forEach(function (k) {
  • 2 o[k] = this._qualifiedExpression(o[k], table);
  • }, this);
  • @@ -15283,19 +15277,19 @@
  • * @return the columns selected
  • * */
  • _selectColumnsSql:function () {
  • -
  • 3583 return " " + this.__columnList(this.__opts.select);
  • +
  • 3620 return " " + this.__columnList(this.__opts.select);
  • },
  • /**@return the DISTINCT clause.*/
  • _selectDistinctSql:function () {
  • -
  • 3583 var distinct = this.__opts.distinct, ret = [];
  • -
  • 3583 if (distinct) {
  • +
  • 3620 var distinct = this.__opts.distinct, ret = [];
  • +
  • 3620 if (distinct) {
  • 10 ret.push(" DISTINCT");
  • 10 if (distinct.length) {
  • 4 ret.push(format(" ON (%s)", this.__expressionList(distinct)));
  • }
  • }
  • -
  • 3583 return ret.join("");
  • +
  • 3620 return ret.join("");
  • },
  • /**
  • @@ -15304,30 +15298,30 @@
  • * work on all databases.
  • **/
  • _selectCompoundsSql:function () {
  • -
  • 3583 var opts = this.__opts, compounds = opts.compounds, ret = [];
  • -
  • 3583 if (compounds) {
  • +
  • 3620 var opts = this.__opts, compounds = opts.compounds, ret = [];
  • +
  • 3620 if (compounds) {
  • 49 compounds.forEach(function (c) {
  • 49 var type = c[0], dataset = c[1], all = c[2];
  • 49 ret.push(string.format(" %s%s %s", type.toUpperCase(), all ? " ALL" : "", this._subselectSql(dataset)));
  • }, this);
  • }
  • -
  • 3583 return ret.join("");
  • +
  • 3620 return ret.join("");
  • },
  • /**
  • * @return the sql to add the list of tables to select FROM
  • **/
  • _selectFromSql:function () {
  • -
  • 3601 var from = this.__opts.from;
  • -
  • 3601 return from ? string.format(" %s%s", this._static.FROM, this._sourceList(from)) : "";
  • +
  • 3638 var from = this.__opts.from;
  • +
  • 3638 return from ? string.format(" %s%s", this._static.FROM, this._sourceList(from)) : "";
  • },
  • /**
  • * @return the GROUP BY clause
  • **/
  • _selectGroupSql:function () {
  • -
  • 3583 var group = this.__opts.group;
  • -
  • 3583 return group ? string.format(" GROUP BY %s", this.__expressionList(group)) : "";
  • +
  • 3620 var group = this.__opts.group;
  • +
  • 3620 return group ? string.format(" GROUP BY %s", this.__expressionList(group)) : "";
  • },
  • @@ -15335,62 +15329,62 @@
  • *@return the sql to add the filter criteria in the HAVING clause
  • **/
  • _selectHavingSql:function () {
  • -
  • 3583 var having = this.__opts.having;
  • -
  • 3583 return having ? string.format(" HAVING %s", this.literal(having)) : "";
  • +
  • 3620 var having = this.__opts.having;
  • +
  • 3620 return having ? string.format(" HAVING %s", this.literal(having)) : "";
  • },
  • /**
  • * @return the JOIN clause.
  • **/
  • _selectJoinSql:function () {
  • -
  • 3586 var join = this.__opts.join, ret = [];
  • -
  • 3586 if (join) {
  • -
  • 467 join.forEach(function (j) {
  • -
  • 771 ret.push(this.literal(j));
  • +
  • 3623 var join = this.__opts.join, ret = [];
  • +
  • 3623 if (join) {
  • +
  • 503 join.forEach(function (j) {
  • +
  • 951 ret.push(this.literal(j));
  • }, this);
  • }
  • -
  • 3586 return ret.join("");
  • +
  • 3623 return ret.join("");
  • },
  • /**
  • * @return the LIMIT and OFFSET clauses.
  • * */
  • _selectLimitSql:function () {
  • -
  • 3583 var ret = [], limit = this.__opts.limit, offset = this.__opts.offset;
  • -
  • 3583 !isUndefined(limit) && !isNull(limit) && (ret.push(format(" LIMIT %s", this.literal(limit))));
  • -
  • 3583 !isUndefined(offset) && !isNull(offset) && (ret.push(format(" OFFSET %s", this.literal(offset))));
  • -
  • 3583 return ret.join("");
  • +
  • 3620 var ret = [], limit = this.__opts.limit, offset = this.__opts.offset;
  • +
  • 3620 !isUndefined(limit) && !isNull(limit) && (ret.push(format(" LIMIT %s", this.literal(limit))));
  • +
  • 3620 !isUndefined(offset) && !isNull(offset) && (ret.push(format(" OFFSET %s", this.literal(offset))));
  • +
  • 3620 return ret.join("");
  • },
  • /**
  • * @return SQL for different locking modes.
  • **/
  • _selectLockSql:function () {
  • -
  • 3582 var lock = this.__opts.lock, ret = [];
  • -
  • 3582 if (lock) {
  • +
  • 3619 var lock = this.__opts.lock, ret = [];
  • +
  • 3619 if (lock) {
  • 3 if (lock == "update") {
  • 2 ret.push(this._static.FOR_UPDATE);
  • } else {
  • 1 ret.push(" ", lock);
  • }
  • }
  • -
  • 3582 return ret.join("");
  • +
  • 3619 return ret.join("");
  • },
  • /**
  • * @return the SQL ORDER BY clause fragment.
  • */
  • _selectOrderSql:function () {
  • -
  • 3595 var order = this.__opts.order;
  • -
  • 3595 return order ? string.format(" ORDER BY %s", this.__expressionList(order)) : "";
  • +
  • 3632 var order = this.__opts.order;
  • +
  • 3632 return order ? string.format(" ORDER BY %s", this.__expressionList(order)) : "";
  • },
  • /**
  • * @return the SQL WHERE clause fragment.
  • */
  • _selectWhereSql:function () {
  • -
  • 4547 var where = this.__opts.where;
  • -
  • 4547 return where ? string.format(" WHERE %s", this.literal(where)) : "";
  • +
  • 4584 var where = this.__opts.where;
  • +
  • 4584 return where ? string.format(" WHERE %s", this.literal(where)) : "";
  • },
  • /**
  • @@ -15398,8 +15392,8 @@
  • * @param sql
  • */
  • _selectWithSql:function (sql) {
  • -
  • 5509 var wit = this.__opts["with"];
  • -
  • 5509 if (wit && wit.length) {
  • +
  • 5546 var wit = this.__opts["with"];
  • +
  • 5546 if (wit && wit.length) {
  • //sql.length = 0;
  • 8 var base = sql.join("");
  • 8 sql.length = 0;
  • @@ -15542,15 +15536,15 @@
  • * Converts an array of source names into into a comma separated list.
  • **/
  • _sourceList:function (source) {
  • -
  • 5808 if (!Array.isArray(source)) {
  • +
  • 5845 if (!Array.isArray(source)) {
  • 719 source = [source];
  • }
  • -
  • 5808 if (!source || !source.length) {
  • +
  • 5845 if (!source || !source.length) {
  • 0 throw new QueryError("No source specified for the query");
  • }
  • -
  • 5808 return " " + source.map(
  • +
  • 5845 return " " + source.map(
  • function (s) {
  • -
  • 5990 return this.__tableRef(s);
  • +
  • 6027 return this.__tableRef(s);
  • }, this).join(this._static.COMMA_SEPARATOR);
  • },
  • @@ -15560,7 +15554,7 @@
  • * we literalize nonstrings.
  • **/
  • _staticSql:function (sql) {
  • -
  • 49 return isString(sql) ? sql : this.literal(sql);
  • +
  • 51 return isString(sql) ? sql : this.literal(sql);
  • },
  • @@ -15575,7 +15569,7 @@
  • * @returns SQL fragment specifying a table name.
  • **/
  • __tableRef:function (t) {
  • -
  • 6761 return isString(t) ? this._quotedIdentifier(t) : this.literal(t);
  • +
  • 6978 return isString(t) ? this._quotedIdentifier(t) : this.literal(t);
  • },
  • @@ -15605,12 +15599,12 @@
  • getters:{
  • //Same as selectS, not aliased directly to make subclassing simpler.
  • sql:function () {
  • -
  • 653 return this.selectSql;
  • +
  • 654 return this.selectSql;
  • },
  • selectSql:function () {
  • -
  • 3681 if (this.__opts.sql) return this._staticSql(this.__opts.sql);
  • -
  • 3583 else return this._clauseSql("select");
  • +
  • 3722 if (this.__opts.sql) return this._staticSql(this.__opts.sql);
  • +
  • 3620 else return this._clauseSql("select");
  • },
  • deleteSql:function () {
  • @@ -15896,7 +15890,7 @@
  • * @type String
  • */
  • identifierInputMethod:function () {
  • -
  • 12807 return this.__identifierInputMethod;
  • +
  • 13317 return this.__identifierInputMethod;
  • },
  • /**
  • @@ -15908,7 +15902,7 @@
  • * @type String
  • */
  • identifierOutputMethod:function () {
  • -
  • 12807 return this.__identifierOutputMethod;
  • +
  • 13317 return this.__identifierOutputMethod;
  • },
  • /**
  • @@ -15921,7 +15915,7 @@
  • * @default true
  • */
  • quoteIdentifiers:function () {
  • -
  • 12780 return this.__quoteIdentifiers;
  • +
  • 13290 return this.__quoteIdentifiers;
  • }
  • },
  • @@ -16073,10 +16067,10 @@
  • /**@ignore*/
  • constructor: function () {
  • -
  • 25047 if (!Dataset) {
  • +
  • 26500 if (!Dataset) {
  • 1 Dataset = require("../index").Dataset;
  • }
  • -
  • 25047 this._super(arguments);
  • +
  • 26500 this._super(arguments);
  • },
  • @@ -16196,21 +16190,21 @@
  • * @return {comb.Promise} a promise that is resolved when the action has completed.
  • */
  • forEach: function (block, cb) {
  • -
  • 2884 var rowCb, ret;
  • -
  • 2884 if (this.__opts.graph) {
  • +
  • 2922 var rowCb, ret;
  • +
  • 2922 if (this.__opts.graph) {
  • 12 ret = this.graphEach(block);
  • } else {
  • -
  • 2872 ret = this.fetchRows(this.selectSql);
  • -
  • 2872 if ((rowCb = this.rowCb)) {
  • +
  • 2910 ret = this.fetchRows(this.selectSql);
  • +
  • 2910 if ((rowCb = this.rowCb)) {
  • 1209 ret = ret.map(function (r) {
  • 1533 return rowCb(r);
  • });
  • }
  • -
  • 2872 if (block) {
  • +
  • 2910 if (block) {
  • 108 ret = ret.forEach(block);
  • }
  • }
  • -
  • 2884 return ret.classic(cb);
  • +
  • 2922 return ret.classic(cb);
  • },
  • /**
  • @@ -16672,9 +16666,9 @@
  • * @return {comb.Promise} a promise resolved with the array of mapped values.
  • */
  • map: function (column, cb) {
  • -
  • 428 var ret = this.forEach();
  • -
  • 428 column && (ret = ret[isFunction(column) ? "map" : "pluck"](column))
  • -
  • 428 return ret.classic(cb).promise();
  • +
  • 466 var ret = this.forEach();
  • +
  • 466 column && (ret = ret[isFunction(column) ? "map" : "pluck"](column))
  • +
  • 466 return ret.classic(cb).promise();
  • },
  • /**
  • @@ -17088,7 +17082,7 @@
  • * readOnly server unless a specific server is set.
  • */
  • execute: function (sql, opts) {
  • -
  • 2684 return this.db.execute(sql, merge({server: this.__opts.server || "readOnly"}, opts || {}));
  • +
  • 2722 return this.db.execute(sql, merge({server: this.__opts.server || "readOnly"}, opts || {}));
  • },
  • /**
  • @@ -17292,10 +17286,10 @@
  • *
  • */
  • constructor: function () {
  • -
  • 2732 if (comb.isUndefinedOrNull(this.__associations)) {
  • -
  • 2634 this.__associations = {};
  • +
  • 2734 if (comb.isUndefinedOrNull(this.__associations)) {
  • +
  • 2635 this.__associations = {};
  • }
  • -
  • 2732 this._super(arguments);
  • +
  • 2734 this._super(arguments);
  • },
  • reload: function () {
  • @@ -17960,10 +17954,10 @@
  • 186 var ret = null;
  • 186 try {
  • 186 if (!action.action(value)) {
  • -
  • 69 ret = format(actionOpts.message, errOpts);
  • +
  • 71 ret = format(actionOpts.message, errOpts);
  • }
  • } catch (e) {
  • -
  • 28 ret = format(actionOpts.message, errOpts);
  • +
  • 26 ret = format(actionOpts.message, errOpts);
  • }
  • 186 return ret;
  • }
  • @@ -18245,7 +18239,7 @@
    Coverage97.82 - SLOC2349 + SLOC2348 LOC458 Missed10
    @@ -18293,8 +18287,8 @@
  • 1var Dataset;
  • 1function conditionedJoin(type) {
  • -
  • 539 var args = argsToArray(arguments, 1);
  • -
  • 539 return this.joinTable.apply(this, [type].concat(args));
  • +
  • 719 var args = argsToArray(arguments, 1);
  • +
  • 719 return this.joinTable.apply(this, [type].concat(args));
  • }
  • 1function unConditionJoin(type, table) {
  • @@ -18313,17 +18307,17 @@
  • * @ignore
  • */
  • constructor: function () {
  • -
  • 25047 !Dataset && (Dataset = require("../index").Dataset);
  • -
  • 25047 this._super(arguments);
  • -
  • 25047 this._static.CONDITIONED_JOIN_TYPES.forEach(function (type) {
  • -
  • 175329 if (!this[type + "Join"]) {
  • -
  • 175329 this[type + "Join"] = hitch(this, conditionedJoin, type);
  • +
  • 26500 !Dataset && (Dataset = require("../index").Dataset);
  • +
  • 26500 this._super(arguments);
  • +
  • 26500 this._static.CONDITIONED_JOIN_TYPES.forEach(function (type) {
  • +
  • 185500 if (!this[type + "Join"]) {
  • +
  • 185500 this[type + "Join"] = hitch(this, conditionedJoin, type);
  • }
  • }, this);
  • -
  • 25047 this._static.UNCONDITIONED_JOIN_TYPES.forEach(function (type) {
  • -
  • 125235 if (!this[type + "Join"]) {
  • -
  • 125235 this[type + "Join"] = hitch(this, unConditionJoin, type);
  • +
  • 26500 this._static.UNCONDITIONED_JOIN_TYPES.forEach(function (type) {
  • +
  • 132500 if (!this[type + "Join"]) {
  • +
  • 132500 this[type + "Join"] = hitch(this, unConditionJoin, type);
  • }
  • }, this);
  • @@ -18406,7 +18400,7 @@
  • 10 var clause = (tOpts.having ? "having" : "where"), clauseObj = tOpts[clause];
  • 10 if (clauseObj) {
  • 9 var args = argsToArray(arguments);
  • -
  • 9 args = args.length == 1 ? args[0] : args;
  • +
  • 9 args = args.length === 1 ? args[0] : args;
  • 9 var opts = {};
  • 9 opts[clause] = new BooleanExpression("OR", clauseObj, this._filterExpr(args));
  • 9 return this.mergeOptions(opts);
  • @@ -18444,7 +18438,7 @@
  • * @return {patio.Dataset} a cloned dataset with the condition 'or group' added to the WHERE/HAVING clause.
  • */
  • andGroupedOr: function (filterExp) {
  • -
  • 2 return this._addGroupedCondition("AND", "OR", filterExp);
  • +
  • 3 return this._addGroupedCondition("AND", "OR", filterExp);
  • },
  • /**
  • @@ -18515,7 +18509,7 @@
  • 1 return this.or.apply(this, arguments);
  • } else {
  • 1 var args = argsToArray(arguments);
  • -
  • 1 args = args.length == 1 ? args[0] : args;
  • +
  • 1 args = args.length === 1 ? args[0] : args;
  • 1 var opts = {};
  • 1 opts[clause] = this._filterExpr(args, null, "AND");
  • 1 return this.mergeOptions(opts);
  • @@ -18639,17 +18633,17 @@
  • * @return {patio.Dataset} a cloned dataset with the excluded conditions applied to the HAVING/WHERE clause.
  • */
  • exclude: function () {
  • -
  • 69 var cond = argsToArray(arguments), tOpts = this.__opts;
  • -
  • 69 var clause = (tOpts["having"] ? "having" : "where"), clauseObj = tOpts[clause];
  • -
  • 69 cond = cond.length > 1 ? cond : cond[0];
  • -
  • 69 cond = this._filterExpr.call(this, cond);
  • -
  • 69 cond = BooleanExpression.invert(cond);
  • -
  • 69 if (clauseObj) {
  • -
  • 58 cond = new BooleanExpression("AND", clauseObj, cond)
  • +
  • 105 var cond = argsToArray(arguments), tOpts = this.__opts;
  • +
  • 105 var clause = (tOpts["having"] ? "having" : "where"), clauseObj = tOpts[clause];
  • +
  • 105 cond = cond.length > 1 ? cond : cond[0];
  • +
  • 105 cond = this._filterExpr.call(this, cond);
  • +
  • 105 cond = BooleanExpression.invert(cond);
  • +
  • 105 if (clauseObj) {
  • +
  • 94 cond = new BooleanExpression("AND", clauseObj, cond);
  • }
  • -
  • 69 var opts = {};
  • -
  • 69 opts[clause] = cond;
  • -
  • 69 return this.mergeOptions(opts);
  • +
  • 105 var opts = {};
  • +
  • 105 opts[clause] = cond;
  • +
  • 105 return this.mergeOptions(opts);
  • },
  • /**
  • @@ -18720,8 +18714,8 @@
  • * @return {patio.Dataset} a cloned dataset with the filter arumgents applied to the WHERE/HAVING clause.
  • **/
  • filter: function (args, cb) {
  • -
  • 3332 args = [this.__opts["having"] ? "having" : "where"].concat(argsToArray(arguments));
  • -
  • 3332 return this._filter.apply(this, args);
  • +
  • 3440 args = [this.__opts["having"] ? "having" : "where"].concat(argsToArray(arguments));
  • +
  • 3440 return this._filter.apply(this, args);
  • },
  • /**
  • @@ -18770,27 +18764,27 @@
  • * @return {patio.Dataset} a cloned dataset with the FROM clause overridden.
  • */
  • from: function (source) {
  • -
  • 823 source = argsToArray(arguments);
  • -
  • 823 var tableAliasNum = 0, sources = [];
  • -
  • 823 source.forEach(function (s) {
  • -
  • 1005 if (isInstanceOf(s, Dataset)) {
  • +
  • 859 source = argsToArray(arguments);
  • +
  • 859 var tableAliasNum = 0, sources = [];
  • +
  • 859 source.forEach(function (s) {
  • +
  • 1041 if (isInstanceOf(s, Dataset)) {
  • 86 sources.push(new AliasedExpression(s, this._datasetAlias(++tableAliasNum)));
  • -
  • 919 } else if (isHash(s)) {
  • +
  • 955 } else if (isHash(s)) {
  • 3 for (var i in s) {
  • 3 sources.push(new AliasedExpression(new Identifier(i), s[i]));
  • }
  • -
  • 916 } else if (isString(s)) {
  • -
  • 891 sources.push(this.stringToIdentifier(s))
  • +
  • 952 } else if (isString(s)) {
  • +
  • 927 sources.push(this.stringToIdentifier(s));
  • } else {
  • 25 sources.push(s);
  • }
  • }, this);
  • -
  • 823 var o = {from: sources.length ? sources : null}
  • -
  • 823 if (tableAliasNum) {
  • +
  • 859 var o = {from: sources.length ? sources : null};
  • +
  • 859 if (tableAliasNum) {
  • 84 o.numDatasetSources = tableAliasNum;
  • }
  • -
  • 823 return this.mergeOptions(o)
  • +
  • 859 return this.mergeOptions(o);
  • },
  • /**
  • @@ -18818,7 +18812,7 @@
  • 84 var fs = {};
  • 84 var nonSqlOptions = this._static.NON_SQL_OPTIONS;
  • 84 Object.keys(this.__opts).forEach(function (k) {
  • -
  • 302 if (nonSqlOptions.indexOf(k) == -1) {
  • +
  • 302 if (nonSqlOptions.indexOf(k) === -1) {
  • 302 fs[k] = null;
  • }
  • });
  • @@ -18906,7 +18900,7 @@
  • group: function (columns) {
  • 32 columns = argsToArray(arguments);
  • 32 var self = this;
  • -
  • 32 return this.mergeOptions({group: (array.compact(columns).length == 0 ? null : columns.map(function (c) {
  • +
  • 32 return this.mergeOptions({group: (array.compact(columns).length === 0 ? null : columns.map(function (c) {
  • 32 return isString(c) ? self.stringToIdentifier(c) : c;
  • }))});
  • },
  • @@ -18960,7 +18954,7 @@
  • **/
  • having: function () {
  • 12 var cond = argsToArray(arguments).map(function (s) {
  • -
  • 12 return isString(s) && s !== '' ? this.stringToIdentifier(s) : s
  • +
  • 12 return isString(s) && s !== '' ? this.stringToIdentifier(s) : s;
  • }, this);
  • 12 return this._filter.apply(this, ["having"].concat(cond));
  • },
  • @@ -19021,7 +19015,7 @@
  • 3 if (!(having || where)) {
  • 1 throw new QueryError("No current filter");
  • }
  • -
  • 2 var o = {}
  • +
  • 2 var o = {};
  • 2 if (having) {
  • 1 o.having = BooleanExpression.invert(having);
  • }
  • @@ -19037,7 +19031,7 @@
  • * @see patio.Dataset#joinTable
  • */
  • join: function () {
  • -
  • 212 return this.innerJoin.apply(this, arguments);
  • +
  • 320 return this.innerJoin.apply(this, arguments);
  • },
  • /**
  • @@ -19143,96 +19137,96 @@
  • */
  • joinTable: function (type, table, expr, options, cb) {
  • -
  • 634 var args = argsToArray(arguments);
  • -
  • 634 if (isFunction(args[args.length - 1])) {
  • +
  • 814 var args = argsToArray(arguments);
  • +
  • 814 if (isFunction(args[args.length - 1])) {
  • 12 cb = args[args.length - 1];
  • 12 args.pop();
  • } else {
  • -
  • 622 cb = null;
  • +
  • 802 cb = null;
  • }
  • -
  • 634 type = args.shift(), table = args.shift(), expr = args.shift(), options = args.shift();
  • -
  • 634 expr = isUndefined(expr) ? null : expr, options = isUndefined(options) ? {} : options;
  • +
  • 814 type = args.shift(), table = args.shift(), expr = args.shift(), options = args.shift();
  • +
  • 814 expr = isUndefined(expr) ? null : expr, options = isUndefined(options) ? {} : options;
  • -
  • 634 var h;
  • -
  • 634 var usingJoin = isArray(expr) && expr.length && expr.every(function (x) {
  • -
  • 223 return isString(x) || isInstanceOf(x, Identifier)
  • +
  • 814 var h;
  • +
  • 814 var usingJoin = isArray(expr) && expr.length && expr.every(function (x) {
  • +
  • 223 return isString(x) || isInstanceOf(x, Identifier);
  • });
  • -
  • 634 if (usingJoin && !this.supportsJoinUsing) {
  • +
  • 814 if (usingJoin && !this.supportsJoinUsing) {
  • 1 h = {};
  • 1 expr.forEach(function (s) {
  • 1 h[s] = s;
  • });
  • 1 return this.joinTable(type, table, h, options);
  • }
  • -
  • 633 var tableAlias, lastAlias;
  • -
  • 633 if (isHash(options)) {
  • -
  • 623 tableAlias = options.tableAlias;
  • -
  • 623 lastAlias = options.implicitQualifier;
  • +
  • 813 var tableAlias, lastAlias;
  • +
  • 813 if (isHash(options)) {
  • +
  • 803 tableAlias = options.tableAlias;
  • +
  • 803 lastAlias = options.implicitQualifier;
  • 10 } else if (isString(options) || isInstanceOf(options, Identifier)) {
  • 9 tableAlias = options;
  • 9 lastAlias = null;
  • } else {
  • 1 throw new QueryError("Invalid options format for joinTable %j4", [options]);
  • }
  • -
  • 632 var tableAliasNum, tableName;
  • -
  • 632 if (isInstanceOf(table, Dataset)) {
  • +
  • 812 var tableAliasNum, tableName;
  • +
  • 812 if (isInstanceOf(table, Dataset)) {
  • 11 if (!tableAlias) {
  • 6 tableAliasNum = (this.__opts.numDatasetSources || 0) + 1;
  • 6 tableAlias = this._datasetAlias(tableAliasNum);
  • }
  • 11 tableName = tableAlias;
  • } else {
  • -
  • 621 if (!isUndefined(table.tableName)) {
  • +
  • 801 if (!isUndefined(table.tableName)) {
  • 1 table = table.tableName;
  • }
  • -
  • 621 if (isArray(table)) {
  • +
  • 801 if (isArray(table)) {
  • 2 table = table.map(this.stringToIdentifier, this);
  • } else {
  • -
  • 619 table = isString(table) ? this.stringToIdentifier(table) : table;
  • -
  • 619 var parts = this._splitAlias(table), implicitTableAlias = parts[1];
  • -
  • 619 table = parts[0]
  • -
  • 619 tableAlias = tableAlias || implicitTableAlias;
  • -
  • 619 tableName = tableAlias || table;
  • +
  • 799 table = isString(table) ? this.stringToIdentifier(table) : table;
  • +
  • 799 var parts = this._splitAlias(table), implicitTableAlias = parts[1];
  • +
  • 799 table = parts[0];
  • +
  • 799 tableAlias = tableAlias || implicitTableAlias;
  • +
  • 799 tableName = tableAlias || table;
  • }
  • }
  • -
  • 632 var join;
  • -
  • 632 if (!expr && !cb) {
  • +
  • 812 var join;
  • +
  • 812 if (!expr && !cb) {
  • 22 join = new JoinClause(type, table, tableAlias);
  • -
  • 610 } else if (usingJoin) {
  • +
  • 790 } else if (usingJoin) {
  • 9 if (cb) {
  • 1 throw new QueryError("cant use a cb if an array is given");
  • }
  • 8 join = new JoinUsingClause(expr, type, table, tableAlias);
  • } else {
  • -
  • 601 lastAlias = lastAlias || this.__opts["lastJoinedTable"] || this.firstSourceAlias;
  • -
  • 600 if (Expression.isConditionSpecifier(expr)) {
  • -
  • 588 var newExpr = [];
  • -
  • 588 for (var i in expr) {
  • -
  • 909 var val = expr[i];
  • -
  • 909 if (isArray(val) && val.length == 2) {
  • +
  • 781 lastAlias = lastAlias || this.__opts["lastJoinedTable"] || this.firstSourceAlias;
  • +
  • 780 if (Expression.isConditionSpecifier(expr)) {
  • +
  • 768 var newExpr = [];
  • +
  • 768 for (var i in expr) {
  • +
  • 1161 var val = expr[i];
  • +
  • 1161 if (isArray(val) && val.length === 2) {
  • 418 i = val[0], val = val[1];
  • }
  • -
  • 909 var k = this.qualifiedColumnName(i, tableName), v;
  • -
  • 909 if (isInstanceOf(val, Identifier)) {
  • -
  • 405 v = val.qualify(lastAlias);
  • +
  • 1161 var k = this.qualifiedColumnName(i, tableName), v;
  • +
  • 1161 if (isInstanceOf(val, Identifier)) {
  • +
  • 477 v = val.qualify(lastAlias);
  • } else {
  • -
  • 504 v = val;
  • +
  • 684 v = val;
  • }
  • -
  • 909 newExpr.push([k, v]);
  • +
  • 1161 newExpr.push([k, v]);
  • }
  • -
  • 588 expr = newExpr;
  • +
  • 768 expr = newExpr;
  • }
  • -
  • 600 if (isFunction(cb)) {
  • +
  • 780 if (isFunction(cb)) {
  • 11 var expr2 = cb.apply(sql, [tableName, lastAlias, this.__opts.join || []]);
  • 11 expr = expr ? new BooleanExpression("AND", expr, expr2) : expr2;
  • }
  • -
  • 600 join = new JoinOnClause(expr, type, table, tableAlias);
  • +
  • 780 join = new JoinOnClause(expr, type, table, tableAlias);
  • }
  • -
  • 630 var opts = {join: (this.__opts.join || []).concat([join]), lastJoinedTable: tableName};
  • -
  • 630 if (tableAliasNum) {
  • +
  • 810 var opts = {join: (this.__opts.join || []).concat([join]), lastJoinedTable: tableName};
  • +
  • 810 if (tableAliasNum) {
  • 6 opts.numDatasetSources = tableAliasNum;
  • }
  • -
  • 630 return this.mergeOptions(opts);
  • +
  • 810 return this.mergeOptions(opts);
  • },
  • @@ -19264,7 +19258,7 @@
  • 46 if (this.__opts.sql) {
  • 7 return this.fromSelf().limit(limit, offset);
  • }
  • -
  • 39 if (isArray(limit) && limit.length == 2) {
  • +
  • 39 if (isArray(limit) && limit.length === 2) {
  • 1 offset = limit[0];
  • 1 limit = limit[1] - limit[0] + 1;
  • }
  • @@ -19662,13 +19656,13 @@
  • * @return {patio.Dataset} a cloned dataset with the order changed.
  • * */
  • order: function (args) {
  • -
  • 380 args = argsToArray(arguments);
  • -
  • 380 var order = [];
  • -
  • 380 args = compact(args).length ? args : null;
  • -
  • 380 if (args) {
  • -
  • 263 args.forEach(function (a) {
  • -
  • 326 if (isString(a)) {
  • -
  • 204 order.push(this.stringToIdentifier(a));
  • +
  • 416 args = argsToArray(arguments);
  • +
  • 416 var order = [];
  • +
  • 416 args = compact(args).length ? args : null;
  • +
  • 416 if (args) {
  • +
  • 299 args.forEach(function (a) {
  • +
  • 362 if (isString(a)) {
  • +
  • 240 order.push(this.stringToIdentifier(a));
  • 122 } else if (isFunction(a)) {
  • 16 var res = a.apply(sql, [sql]);
  • 16 order = order.concat(isArray(res) ? res : [res]);
  • @@ -19679,7 +19673,7 @@
  • } else {
  • 117 order = null;
  • }
  • -
  • 380 return this.mergeOptions({order: order});
  • +
  • 416 return this.mergeOptions({order: order});
  • },
  • /**
  • @@ -19875,29 +19869,29 @@
  • * @return {patio.Dataset} a cloned dataset with the columns selected changed.
  • */
  • select: function (args) {
  • -
  • 662 args = flatten(argsToArray(arguments));
  • -
  • 662 var columns = [];
  • -
  • 662 args.forEach(function (c) {
  • -
  • 1042 if (isFunction(c)) {
  • +
  • 698 args = flatten(argsToArray(arguments));
  • +
  • 698 var columns = [];
  • +
  • 698 args.forEach(function (c) {
  • +
  • 1258 if (isFunction(c)) {
  • 23 var res = c.apply(sql, [sql]);
  • 23 columns = columns.concat(isArray(res) ? res : [res]);
  • } else {
  • -
  • 1019 columns.push(c);
  • +
  • 1235 columns.push(c);
  • }
  • });
  • -
  • 662 var select = [];
  • -
  • 662 columns.forEach(function (c) {
  • -
  • 1045 if (isHash(c)) {
  • +
  • 698 var select = [];
  • +
  • 698 columns.forEach(function (c) {
  • +
  • 1261 if (isHash(c)) {
  • 4 for (var i in c) {
  • 5 select.push(new AliasedExpression(this.stringToIdentifier(i), c[i]));
  • }
  • -
  • 1041 } else if (isString(c)) {
  • -
  • 344 select.push(this.stringToIdentifier(c));
  • +
  • 1257 } else if (isString(c)) {
  • +
  • 416 select.push(this.stringToIdentifier(c));
  • } else {
  • -
  • 697 select.push(c);
  • +
  • 841 select.push(c);
  • }
  • }, this);
  • -
  • 662 return this.mergeOptions({select: select});
  • +
  • 698 return this.mergeOptions({select: select});
  • },
  • @@ -20195,7 +20189,7 @@
  • 1 throw new QueryError("This dataset does not support common table expressions");
  • }
  • 6 opts = opts || {};
  • -
  • 6 var wit = (this.__opts["with"] || []).concat([merge(opts, {recursive: true, name: this.stringToIdentifier(name), dataset: nonRecursive.union(recursive, {all: opts.unionAll != false, fromSelf: false})})]);
  • +
  • 6 var wit = (this.__opts["with"] || []).concat([merge(opts, {recursive: true, name: this.stringToIdentifier(name), dataset: nonRecursive.union(recursive, {all: opts.unionAll !== false, fromSelf: false})})]);
  • 6 return this.mergeOptions({"with": wit});
  • },
  • @@ -20213,11 +20207,11 @@
  • * @return {patio.Dataset} a cloned dataset with the static sql set.
  • */
  • withSql: function (sql) {
  • -
  • 44 var args = argsToArray(arguments).slice(1);
  • -
  • 44 if (args.length) {
  • -
  • 21 sql = new PlaceHolderLiteralString(sql, args)
  • +
  • 46 var args = argsToArray(arguments).slice(1);
  • +
  • 46 if (args.length) {
  • +
  • 23 sql = new PlaceHolderLiteralString(sql, args);
  • }
  • -
  • 44 return this.mergeOptions({sql: sql});
  • +
  • 46 return this.mergeOptions({sql: sql});
  • },
  • @@ -20293,20 +20287,20 @@
  • * @return {patio.Dataset} a cloned dataset with the condition group added to the WHERE/HAVING clause.
  • */
  • _addGroupedCondition: function (addedByBool, groupedByBool) {
  • -
  • 6 groupedByBool = isUndefined(groupedByBool) ? "AND" : groupedByBool;
  • -
  • 6 var tOpts = this.__opts,
  • +
  • 7 groupedByBool = isUndefined(groupedByBool) ? "AND" : groupedByBool;
  • +
  • 7 var tOpts = this.__opts,
  • clause = (tOpts.having ? "having" : "where"),
  • clauseObj = tOpts[clause];
  • -
  • 6 var args = argsToArray(arguments, 2);
  • -
  • 6 args = args.length == 1 ? args[0] : args;
  • -
  • 6 var opts = {};
  • -
  • 6 if (clauseObj) {
  • -
  • 3 addedByBool = isUndefined(addedByBool) ? "AND" : addedByBool;
  • -
  • 3 opts[clause] = new BooleanExpression(addedByBool, clauseObj, this._filterExpr(args, null, groupedByBool));
  • +
  • 7 var args = argsToArray(arguments, 2);
  • +
  • 7 args = args.length === 1 ? args[0] : args;
  • +
  • 7 var opts = {};
  • +
  • 7 if (clauseObj) {
  • +
  • 4 addedByBool = isUndefined(addedByBool) ? "AND" : addedByBool;
  • +
  • 4 opts[clause] = new BooleanExpression(addedByBool, clauseObj, this._filterExpr(args, null, groupedByBool));
  • } else {
  • 3 opts[clause] = this._filterExpr(args, null, groupedByBool);
  • }
  • -
  • 6 return this.mergeOptions(opts);
  • +
  • 7 return this.mergeOptions(opts);
  • },
  • /**
  • @@ -20316,20 +20310,20 @@
  • * Internal filter method so it works on either the having or where clauses.
  • */
  • _filter: function (clause) {
  • -
  • 3629 var cond = argsToArray(arguments).slice(1), cb;
  • -
  • 3629 if (cond.length && isFunction(cond[cond.length - 1])) {
  • +
  • 3737 var cond = argsToArray(arguments).slice(1), cb;
  • +
  • 3737 if (cond.length && isFunction(cond[cond.length - 1])) {
  • 59 cb = cond.pop();
  • }
  • -
  • 3629 cond = cond.length == 1 ? cond[0] : cond
  • -
  • 3629 if ((cond == null || cond == undefined || cond === "") || (isArray(cond) && cond.length == 0 && !cb) || (isObject(cond) && isEmpty(cond) && !cb)) {
  • +
  • 3737 cond = cond.length === 1 ? cond[0] : cond;
  • +
  • 3737 if ((cond == null || cond === undefined || cond === "") || (isArray(cond) && cond.length === 0 && !cb) || (isObject(cond) && isEmpty(cond) && !cb)) {
  • 293 return this.mergeOptions();
  • } else {
  • -
  • 3336 cond = this._filterExpr(cond, cb);
  • -
  • 3333 var cl = this.__opts[clause];
  • -
  • 3333 cl && (cond = new BooleanExpression("AND", cl, cond));
  • -
  • 3333 var opts = {};
  • -
  • 3333 opts[clause] = cond;
  • -
  • 3333 return this.mergeOptions(opts);
  • +
  • 3444 cond = this._filterExpr(cond, cb);
  • +
  • 3441 var cl = this.__opts[clause];
  • +
  • 3441 cl && (cond = new BooleanExpression("AND", cl, cond));
  • +
  • 3441 var opts = {};
  • +
  • 3441 opts[clause] = cond;
  • +
  • 3441 return this.mergeOptions(opts);
  • }
  • },
  • @@ -20340,10 +20334,10 @@
  • * string that does not contain an alias {table}___{alias}.
  • */
  • _splitAlias: function (c) {
  • -
  • 619 var ret;
  • -
  • 619 if (isInstanceOf(c, AliasedExpression)) {
  • +
  • 799 var ret;
  • +
  • 799 if (isInstanceOf(c, AliasedExpression)) {
  • 5 ret = [c.expression, c.alias];
  • -
  • 614 } else if (isString(c)) {
  • +
  • 794 } else if (isString(c)) {
  • 0 var parts = this._splitString(c), cTable = parts[0], column = parts[1], alias = parts[2];
  • 0 if (alias) {
  • 0 ret = [cTable ? new QualifiedIdentifier(cTable, column) : column, alias];
  • @@ -20351,9 +20345,9 @@
  • 0 ret = [c, null];
  • }
  • } else {
  • -
  • 614 ret = [c, null];
  • +
  • 794 ret = [c, null];
  • }
  • -
  • 619 return ret;
  • +
  • 799 return ret;
  • },
  • @@ -20405,7 +20399,7 @@
  • 42 pairs.push(new BooleanExpression(op, new Identifier(pair[0]), pair[1]));
  • });
  • }
  • -
  • 32 return pairs.length == 1 ? pairs[0] : BooleanExpression.fromArgs(["AND"].concat(pairs));
  • +
  • 32 return pairs.length === 1 ? pairs[0] : BooleanExpression.fromArgs(["AND"].concat(pairs));
  • },
  • /**
  • @@ -20434,7 +20428,7 @@
  • 2 throw new QueryError("Between requires an array for the value");
  • }
  • }
  • -
  • 2 var ret = pairs.length == 1 ? pairs[0] : BooleanExpression.fromArgs(["AND"].concat(pairs))
  • +
  • 2 var ret = pairs.length === 1 ? pairs[0] : BooleanExpression.fromArgs(["AND"].concat(pairs));
  • 2 return invert ? BooleanExpression.invert(ret) : ret;
  • },
  • @@ -20472,40 +20466,40 @@
  • * SQL expression object based on the expr type. See {@link patio.Dataset#filter}
  • */
  • _filterExpr: function (expr, cb, joinCond) {
  • -
  • 4159 expr = (isUndefined(expr) || isNull(expr) || (isArray(expr) && !expr.length)) ? null : expr;
  • -
  • 4159 if (expr && cb) {
  • -
  • 1 return new BooleanExpression(joinCond || "AND", this._filterExpr(expr, null, joinCond), this._filterExpr(cb, null, joinCond))
  • -
  • 4158 } else if (cb) {
  • -
  • 58 expr = cb
  • +
  • 4484 expr = (isUndefined(expr) || isNull(expr) || (isArray(expr) && !expr.length)) ? null : expr;
  • +
  • 4484 if (expr && cb) {
  • +
  • 1 return new BooleanExpression(joinCond || "AND", this._filterExpr(expr, null, joinCond), this._filterExpr(cb, null, joinCond));
  • +
  • 4483 } else if (cb) {
  • +
  • 58 expr = cb;
  • }
  • -
  • 4158 if (isInstanceOf(expr, Expression)) {
  • +
  • 4483 if (isInstanceOf(expr, Expression)) {
  • 427 if (isInstanceOf(expr, NumericExpression, StringExpression)) {
  • 2 throw new QueryError("Invalid SQL Expression type : " + expr);
  • }
  • 425 return expr;
  • -
  • 3731 } else if (isArray(expr)) {
  • -
  • 744 if (expr.length) {
  • -
  • 744 var first = expr[0];
  • -
  • 744 if (isString(first)) {
  • +
  • 4056 } else if (isArray(expr)) {
  • +
  • 924 if (expr.length) {
  • +
  • 924 var first = expr[0];
  • +
  • 924 if (isString(first)) {
  • 25 return new PlaceHolderLiteralString(first, expr.slice(1), true);
  • -
  • 719 } else if (Expression.isConditionSpecifier(expr)) {
  • -
  • 708 return BooleanExpression.fromValuePairs(expr, joinCond)
  • +
  • 899 } else if (Expression.isConditionSpecifier(expr)) {
  • +
  • 888 return BooleanExpression.fromValuePairs(expr, joinCond);
  • } else {
  • 11 return BooleanExpression.fromArgs([joinCond || "AND"].concat(expr.map(function (e) {
  • 23 return this._filterExpr(e, null, joinCond);
  • }, this)));
  • }
  • }
  • -
  • 2987 } else if (isFunction(expr)) {
  • +
  • 3132 } else if (isFunction(expr)) {
  • 59 return this._filterExpr(expr.call(sql, sql), null, joinCond);
  • -
  • 2928 } else if (isBoolean(expr)) {
  • +
  • 3073 } else if (isBoolean(expr)) {
  • 7 return new BooleanExpression("NOOP", expr);
  • -
  • 2921 } else if (isString(expr)) {
  • +
  • 3066 } else if (isString(expr)) {
  • 1 return this.stringToIdentifier(expr);
  • -
  • 2920 } else if (isInstanceOf(expr, LiteralString)) {
  • +
  • 3065 } else if (isInstanceOf(expr, LiteralString)) {
  • 16 return new LiteralString("(" + expr + ")");
  • -
  • 2904 } else if (isHash(expr)) {
  • -
  • 2903 return BooleanExpression.fromValuePairs(expr, joinCond);
  • +
  • 3049 } else if (isHash(expr)) {
  • +
  • 3048 return BooleanExpression.fromValuePairs(expr, joinCond);
  • } else {
  • 1 throw new QueryError("Invalid filter argument");
  • }
  • @@ -20522,13 +20516,13 @@
  • isSimpleSelectAll: function () {
  • 33 var o = {}, opts = this.__opts, count = 0;
  • 33 for (var i in opts) {
  • -
  • 70 if (opts[i] != null && this._static.NON_SQL_OPTIONS.indexOf(i) == -1) {
  • +
  • 70 if (opts[i] != null && this._static.NON_SQL_OPTIONS.indexOf(i) === -1) {
  • 37 o[i] = opts[i];
  • 37 count++;
  • }
  • }
  • -
  • 33 var f = o.from
  • -
  • 33 return count == 1 && f.length == 1 && (isString(f[0]) || isInstanceOf(f[0], AliasedExpression, Identifier));
  • +
  • 33 var f = o.from;
  • +
  • 33 return count === 1 && f.length === 1 && (isString(f[0]) || isInstanceOf(f[0], AliasedExpression, Identifier));
  • }
  • }
  • },
  • @@ -20599,8 +20593,7 @@
  • 35 this.QUERY_METHODS = queryMethods.concat(joinMethods);
  • }
  • }
  • -
  • }).
  • -
  • as(module);
  • +
  • }).as(module);
  • @@ -20983,8 +20976,8 @@
  • * @ignore
  • */
  • constructor: function () {
  • -
  • 25047 !Dataset && (Dataset = require("../index").Dataset);
  • -
  • 25047 this._super(arguments);
  • +
  • 26500 !Dataset && (Dataset = require("../index").Dataset);
  • +
  • 26500 this._super(arguments);
  • },
  • /**
  • @@ -21657,8 +21650,8 @@
  • * Logs an INFO level message to the "patio.Database" logger.
  • */
  • logInfo: function () {
  • -
  • 7192 if (LOGGER.isInfo) {
  • -
  • 7192 LOGGER.info.apply(LOGGER, arguments);
  • +
  • 7230 if (LOGGER.isInfo) {
  • +
  • 7230 LOGGER.info.apply(LOGGER, arguments);
  • }
  • },
  • @@ -21666,8 +21659,8 @@
  • * Logs a DEBUG level message to the "patio.Database" logger.
  • */
  • logDebug: function () {
  • -
  • 6884 if (LOGGER.isDebug) {
  • -
  • 6884 LOGGER.debug.apply(LOGGER, arguments);
  • +
  • 6922 if (LOGGER.isDebug) {
  • +
  • 6922 LOGGER.debug.apply(LOGGER, arguments);
  • }
  • },
  • @@ -21711,23 +21704,23 @@
  • * and all other queries with the duration at warn or info level.
  • * */
  • __logAndExecute: function (sql, args, cb) {
  • -
  • 6956 if (isFunction(args)) {
  • -
  • 6953 cb = args;
  • -
  • 6953 args = null;
  • +
  • 6994 if (isFunction(args)) {
  • +
  • 6991 cb = args;
  • +
  • 6991 args = null;
  • }
  • -
  • 6956 if (args) {
  • +
  • 6994 if (args) {
  • 2 sql = format("%s; %j", sql, args);
  • }
  • -
  • 6956 sql = sql.trim();
  • -
  • 6956 var start = new Date(), self = this;
  • -
  • 6956 var ret;
  • -
  • 6956 if (isFunction(cb)) {
  • -
  • 6955 this.logInfo("Executing; %s", sql);
  • -
  • 6955 ret = new Promise();
  • -
  • 6955 cb().chain(function () {
  • -
  • 6883 self.logDebug("Duration: % 6dms; %s", new Date() - start, sql);
  • -
  • 6883 spreadArgs(ret.callback, arguments);
  • +
  • 6994 sql = sql.trim();
  • +
  • 6994 var start = new Date(), self = this;
  • +
  • 6994 var ret;
  • +
  • 6994 if (isFunction(cb)) {
  • +
  • 6993 this.logInfo("Executing; %s", sql);
  • +
  • 6993 ret = new Promise();
  • +
  • 6993 cb().chain(function () {
  • +
  • 6921 self.logDebug("Duration: % 6dms; %s", new Date() - start, sql);
  • +
  • 6921 spreadArgs(ret.callback, arguments);
  • },function (err) {
  • 72 err = new QueryError(format("%s: %s", err.message, sql));
  • 72 self.logError(err);
  • @@ -21736,7 +21729,7 @@
  • } else {
  • 1 throw new QueryError("CB is required");
  • }
  • -
  • 6955 return ret.promise();
  • +
  • 6993 return ret.promise();
  • },
  • /*Log the given SQL and then execute it on the connection, used by
  • @@ -21875,7 +21868,7 @@
  • // Whether this dataset quotes identifiers.
  • /**@ignore*/
  • quoteIdentifiers:function(){
  • -
  • 42012 return this.__quoteIdentifiers;
  • +
  • 44457 return this.__quoteIdentifiers;
  • },
  • // Whether this dataset will provide accurate number of rows matched for
  • @@ -21883,80 +21876,80 @@
  • // rows matched by the dataset's filter.
  • /**@ignore*/
  • providesAccurateRowsMatched:function(){
  • -
  • 13168 return this.__providesAccurateRowsMatched;
  • +
  • 13603 return this.__providesAccurateRowsMatched;
  • },
  • //Whether the dataset requires SQL standard datetimes (false by default,
  • // as most allow strings with ISO 8601 format).
  • /**@ignore*/
  • requiresSqlStandardDateTimes:function(){
  • -
  • 13175 return this.__requiresSqlStandardDateTimes;
  • +
  • 13610 return this.__requiresSqlStandardDateTimes;
  • },
  • // Whether the dataset supports common table expressions (the WITH clause).
  • /**@ignore*/
  • supportsCte:function(){
  • -
  • 13181 return this.__supportsCte;
  • +
  • 13616 return this.__supportsCte;
  • },
  • // Whether the dataset supports the DISTINCT ON clause, false by default.
  • /**@ignore*/
  • supportsDistinctOn:function(){
  • -
  • 2294 return this.__supportsDistinctOn;
  • +
  • 2297 return this.__supportsDistinctOn;
  • },
  • //Whether the dataset supports the INTERSECT and EXCEPT compound operations, true by default.
  • /**@ignore*/
  • supportsIntersectExcept:function(){
  • -
  • 13204 return this.__supportsIntersectExcept;
  • +
  • 13639 return this.__supportsIntersectExcept;
  • },
  • //Whether the dataset supports the INTERSECT ALL and EXCEPT ALL compound operations, true by default.
  • /**@ignore*/
  • supportsIntersectExceptAll:function(){
  • -
  • 13180 return this.__supportsIntersectExceptAll;
  • +
  • 13615 return this.__supportsIntersectExceptAll;
  • },
  • //Whether the dataset supports the IS TRUE syntax.
  • /**@ignore*/
  • supportsIsTrue:function(){
  • -
  • 13377 return this.__supportsIsTrue;
  • +
  • 13884 return this.__supportsIsTrue;
  • },
  • //Whether the dataset supports the JOIN table USING (column1, ...) syntax.
  • /**@ignore*/
  • supportsJoinUsing:function(){
  • -
  • 13179 return this.__supportsJoinUsing;
  • +
  • 13614 return this.__supportsJoinUsing;
  • },
  • //Whether modifying joined datasets is supported.
  • /**@ignore*/
  • supportsModifyingJoins:function(){
  • -
  • 2534 return this.__supportsModifyingJoins;
  • +
  • 2537 return this.__supportsModifyingJoins;
  • },
  • //Whether the IN/NOT IN operators support multiple columns when an
  • /**@ignore*/
  • supportsMultipleColumnIn:function(){
  • -
  • 13172 return this.__supportsMultipleColumnIn;
  • +
  • 13607 return this.__supportsMultipleColumnIn;
  • },
  • //Whether the dataset supports timezones in literal timestamps
  • /**@ignore*/
  • supportsTimestampTimezones:function(){
  • -
  • 2291 return this.__supportsTimestampTimezones;
  • +
  • 2294 return this.__supportsTimestampTimezones;
  • },
  • //Whether the dataset supports fractional seconds in literal timestamps
  • /**@ignore*/
  • supportsTimestampUsecs:function(){
  • -
  • 13168 return this.__supportsTimestampUsecs;
  • +
  • 13603 return this.__supportsTimestampUsecs;
  • },
  • //Whether the dataset supports window functions.
  • /**@ignore*/
  • supportsWindowFunctions:function(){
  • -
  • 13168 return this.__supportsWindowFunctions;
  • +
  • 13603 return this.__supportsWindowFunctions;
  • }
  • },
  • @@ -21967,7 +21960,7 @@
  • // Whether this dataset quotes identifiers.
  • /**@ignore*/
  • quoteIdentifiers:function(val){
  • -
  • 13180 this.__quoteIdentifiers = val;
  • +
  • 13615 this.__quoteIdentifiers = val;
  • },
  • // Whether this dataset will provide accurate number of rows matched for
  • @@ -21975,80 +21968,80 @@
  • // rows matched by the dataset's filter.
  • /**@ignore*/
  • providesAccurateRowsMatched:function(val){
  • -
  • 13168 this.__providesAccurateRowsMatched = val;
  • +
  • 13603 this.__providesAccurateRowsMatched = val;
  • },
  • //Whether the dataset requires SQL standard datetimes (false by default,
  • // as most allow strings with ISO 8601 format).
  • /**@ignore*/
  • requiresSqlStandardDateTimes:function(val){
  • -
  • 13168 this.__requiresSqlStandardDateTimes = val;
  • +
  • 13603 this.__requiresSqlStandardDateTimes = val;
  • },
  • // Whether the dataset supports common table expressions (the WITH clause).
  • /**@ignore*/
  • supportsCte:function(val){
  • -
  • 13169 this.__supportsCte = val;
  • +
  • 13604 this.__supportsCte = val;
  • },
  • // Whether the dataset supports the DISTINCT ON clause, false by default.
  • /**@ignore*/
  • supportsDistinctOn:function(val){
  • -
  • 2292 this.__supportsDistinctOn = val;
  • +
  • 2295 this.__supportsDistinctOn = val;
  • },
  • //Whether the dataset supports the INTERSECT and EXCEPT compound operations, true by default.
  • /**@ignore*/
  • supportsIntersectExcept:function(val){
  • -
  • 13170 this.__supportsIntersectExcept = val;
  • +
  • 13605 this.__supportsIntersectExcept = val;
  • },
  • //Whether the dataset supports the INTERSECT ALL and EXCEPT ALL compound operations, true by default.
  • /**@ignore*/
  • supportsIntersectExceptAll:function(val){
  • -
  • 13170 this.__supportsIntersectExceptAll = val;
  • +
  • 13605 this.__supportsIntersectExceptAll = val;
  • },
  • //Whether the dataset supports the IS TRUE syntax.
  • /**@ignore*/
  • supportsIsTrue:function(val){
  • -
  • 13168 this.__supportsIsTrue = val;
  • +
  • 13603 this.__supportsIsTrue = val;
  • },
  • //Whether the dataset supports the JOIN table USING (column1, ...) syntax.
  • /**@ignore*/
  • supportsJoinUsing:function(val){
  • -
  • 13170 this.__supportsJoinUsing = val;
  • +
  • 13605 this.__supportsJoinUsing = val;
  • },
  • //Whether modifying joined datasets is supported.
  • /**@ignore*/
  • supportsModifyingJoins:function(val){
  • -
  • 2292 this.__supportsModifyingJoins = val;
  • +
  • 2295 this.__supportsModifyingJoins = val;
  • },
  • //Whether the IN/NOT IN operators support multiple columns when an
  • /**@ignore*/
  • supportsMultipleColumnIn:function(val){
  • -
  • 13168 this.__supportsMultipleColumnIn = val;
  • +
  • 13603 this.__supportsMultipleColumnIn = val;
  • },
  • //Whether the dataset supports timezones in literal timestamps
  • /**@ignore*/
  • supportsTimestampTimezones:function(val){
  • -
  • 2291 this.__supportsTimestampTimezones = val;
  • +
  • 2294 this.__supportsTimestampTimezones = val;
  • },
  • //Whether the dataset supports fractional seconds in literal timestamps
  • /**@ignore*/
  • supportsTimestampUsecs:function(val){
  • -
  • 13168 this.__supportsTimestampUsecs = val;
  • +
  • 13603 this.__supportsTimestampUsecs = val;
  • },
  • //Whether the dataset supports window functions.
  • /**@ignore*/
  • supportsWindowFunctions:function(val){
  • -
  • 13168 this.__supportsWindowFunctions = val;
  • +
  • 13603 this.__supportsWindowFunctions = val;
  • }
  • }
  • diff --git a/docs/History.html b/docs/History.html index 697d43b7..5829e5b8 100644 --- a/docs/History.html +++ b/docs/History.html @@ -360,6 +360,11 @@ +

    v0.2.15

    +

    v0.2.14

    +
  • }).as(module);
  • @@ -20983,8 +20976,8 @@
  • * @ignore
  • */
  • constructor: function () {
  • -
  • 25047 !Dataset && (Dataset = require("../index").Dataset);
  • -
  • 25047 this._super(arguments);
  • +
  • 26500 !Dataset && (Dataset = require("../index").Dataset);
  • +
  • 26500 this._super(arguments);
  • },
  • /**
  • @@ -21657,8 +21650,8 @@
  • * Logs an INFO level message to the "patio.Database" logger.
  • */
  • logInfo: function () {
  • -
  • 7192 if (LOGGER.isInfo) {
  • -
  • 7192 LOGGER.info.apply(LOGGER, arguments);
  • +
  • 7230 if (LOGGER.isInfo) {
  • +
  • 7230 LOGGER.info.apply(LOGGER, arguments);
  • }
  • },
  • @@ -21666,8 +21659,8 @@
  • * Logs a DEBUG level message to the "patio.Database" logger.
  • */
  • logDebug: function () {
  • -
  • 6884 if (LOGGER.isDebug) {
  • -
  • 6884 LOGGER.debug.apply(LOGGER, arguments);
  • +
  • 6922 if (LOGGER.isDebug) {
  • +
  • 6922 LOGGER.debug.apply(LOGGER, arguments);
  • }
  • },
  • @@ -21711,23 +21704,23 @@
  • * and all other queries with the duration at warn or info level.
  • * */
  • __logAndExecute: function (sql, args, cb) {
  • -
  • 6956 if (isFunction(args)) {
  • -
  • 6953 cb = args;
  • -
  • 6953 args = null;
  • +
  • 6994 if (isFunction(args)) {
  • +
  • 6991 cb = args;
  • +
  • 6991 args = null;
  • }
  • -
  • 6956 if (args) {
  • +
  • 6994 if (args) {
  • 2 sql = format("%s; %j", sql, args);
  • }
  • -
  • 6956 sql = sql.trim();
  • -
  • 6956 var start = new Date(), self = this;
  • -
  • 6956 var ret;
  • -
  • 6956 if (isFunction(cb)) {
  • -
  • 6955 this.logInfo("Executing; %s", sql);
  • -
  • 6955 ret = new Promise();
  • -
  • 6955 cb().chain(function () {
  • -
  • 6883 self.logDebug("Duration: % 6dms; %s", new Date() - start, sql);
  • -
  • 6883 spreadArgs(ret.callback, arguments);
  • +
  • 6994 sql = sql.trim();
  • +
  • 6994 var start = new Date(), self = this;
  • +
  • 6994 var ret;
  • +
  • 6994 if (isFunction(cb)) {
  • +
  • 6993 this.logInfo("Executing; %s", sql);
  • +
  • 6993 ret = new Promise();
  • +
  • 6993 cb().chain(function () {
  • +
  • 6921 self.logDebug("Duration: % 6dms; %s", new Date() - start, sql);
  • +
  • 6921 spreadArgs(ret.callback, arguments);
  • },function (err) {
  • 72 err = new QueryError(format("%s: %s", err.message, sql));
  • 72 self.logError(err);
  • @@ -21736,7 +21729,7 @@
  • } else {
  • 1 throw new QueryError("CB is required");
  • }
  • -
  • 6955 return ret.promise();
  • +
  • 6993 return ret.promise();
  • },
  • /*Log the given SQL and then execute it on the connection, used by
  • @@ -21875,7 +21868,7 @@
  • // Whether this dataset quotes identifiers.
  • /**@ignore*/
  • quoteIdentifiers:function(){
  • -
  • 42012 return this.__quoteIdentifiers;
  • +
  • 44457 return this.__quoteIdentifiers;
  • },
  • // Whether this dataset will provide accurate number of rows matched for
  • @@ -21883,80 +21876,80 @@
  • // rows matched by the dataset's filter.
  • /**@ignore*/
  • providesAccurateRowsMatched:function(){
  • -
  • 13168 return this.__providesAccurateRowsMatched;
  • +
  • 13603 return this.__providesAccurateRowsMatched;
  • },
  • //Whether the dataset requires SQL standard datetimes (false by default,
  • // as most allow strings with ISO 8601 format).
  • /**@ignore*/
  • requiresSqlStandardDateTimes:function(){
  • -
  • 13175 return this.__requiresSqlStandardDateTimes;
  • +
  • 13610 return this.__requiresSqlStandardDateTimes;
  • },
  • // Whether the dataset supports common table expressions (the WITH clause).
  • /**@ignore*/
  • supportsCte:function(){
  • -
  • 13181 return this.__supportsCte;
  • +
  • 13616 return this.__supportsCte;
  • },
  • // Whether the dataset supports the DISTINCT ON clause, false by default.
  • /**@ignore*/
  • supportsDistinctOn:function(){
  • -
  • 2294 return this.__supportsDistinctOn;
  • +
  • 2297 return this.__supportsDistinctOn;
  • },
  • //Whether the dataset supports the INTERSECT and EXCEPT compound operations, true by default.
  • /**@ignore*/
  • supportsIntersectExcept:function(){
  • -
  • 13204 return this.__supportsIntersectExcept;
  • +
  • 13639 return this.__supportsIntersectExcept;
  • },
  • //Whether the dataset supports the INTERSECT ALL and EXCEPT ALL compound operations, true by default.
  • /**@ignore*/
  • supportsIntersectExceptAll:function(){
  • -
  • 13180 return this.__supportsIntersectExceptAll;
  • +
  • 13615 return this.__supportsIntersectExceptAll;
  • },
  • //Whether the dataset supports the IS TRUE syntax.
  • /**@ignore*/
  • supportsIsTrue:function(){
  • -
  • 13377 return this.__supportsIsTrue;
  • +
  • 13884 return this.__supportsIsTrue;
  • },
  • //Whether the dataset supports the JOIN table USING (column1, ...) syntax.
  • /**@ignore*/
  • supportsJoinUsing:function(){
  • -
  • 13179 return this.__supportsJoinUsing;
  • +
  • 13614 return this.__supportsJoinUsing;
  • },
  • //Whether modifying joined datasets is supported.
  • /**@ignore*/
  • supportsModifyingJoins:function(){
  • -
  • 2534 return this.__supportsModifyingJoins;
  • +
  • 2537 return this.__supportsModifyingJoins;
  • },
  • //Whether the IN/NOT IN operators support multiple columns when an
  • /**@ignore*/
  • supportsMultipleColumnIn:function(){
  • -
  • 13172 return this.__supportsMultipleColumnIn;
  • +
  • 13607 return this.__supportsMultipleColumnIn;
  • },
  • //Whether the dataset supports timezones in literal timestamps
  • /**@ignore*/
  • supportsTimestampTimezones:function(){
  • -
  • 2291 return this.__supportsTimestampTimezones;
  • +
  • 2294 return this.__supportsTimestampTimezones;
  • },
  • //Whether the dataset supports fractional seconds in literal timestamps
  • /**@ignore*/
  • supportsTimestampUsecs:function(){
  • -
  • 13168 return this.__supportsTimestampUsecs;
  • +
  • 13603 return this.__supportsTimestampUsecs;
  • },
  • //Whether the dataset supports window functions.
  • /**@ignore*/
  • supportsWindowFunctions:function(){
  • -
  • 13168 return this.__supportsWindowFunctions;
  • +
  • 13603 return this.__supportsWindowFunctions;
  • }
  • },
  • @@ -21967,7 +21960,7 @@
  • // Whether this dataset quotes identifiers.
  • /**@ignore*/
  • quoteIdentifiers:function(val){
  • -
  • 13180 this.__quoteIdentifiers = val;
  • +
  • 13615 this.__quoteIdentifiers = val;
  • },
  • // Whether this dataset will provide accurate number of rows matched for
  • @@ -21975,80 +21968,80 @@
  • // rows matched by the dataset's filter.
  • /**@ignore*/
  • providesAccurateRowsMatched:function(val){
  • -
  • 13168 this.__providesAccurateRowsMatched = val;
  • +
  • 13603 this.__providesAccurateRowsMatched = val;
  • },
  • //Whether the dataset requires SQL standard datetimes (false by default,
  • // as most allow strings with ISO 8601 format).
  • /**@ignore*/
  • requiresSqlStandardDateTimes:function(val){
  • -
  • 13168 this.__requiresSqlStandardDateTimes = val;
  • +
  • 13603 this.__requiresSqlStandardDateTimes = val;
  • },
  • // Whether the dataset supports common table expressions (the WITH clause).
  • /**@ignore*/
  • supportsCte:function(val){
  • -
  • 13169 this.__supportsCte = val;
  • +
  • 13604 this.__supportsCte = val;
  • },
  • // Whether the dataset supports the DISTINCT ON clause, false by default.
  • /**@ignore*/
  • supportsDistinctOn:function(val){
  • -
  • 2292 this.__supportsDistinctOn = val;
  • +
  • 2295 this.__supportsDistinctOn = val;
  • },
  • //Whether the dataset supports the INTERSECT and EXCEPT compound operations, true by default.
  • /**@ignore*/
  • supportsIntersectExcept:function(val){
  • -
  • 13170 this.__supportsIntersectExcept = val;
  • +
  • 13605 this.__supportsIntersectExcept = val;
  • },
  • //Whether the dataset supports the INTERSECT ALL and EXCEPT ALL compound operations, true by default.
  • /**@ignore*/
  • supportsIntersectExceptAll:function(val){
  • -
  • 13170 this.__supportsIntersectExceptAll = val;
  • +
  • 13605 this.__supportsIntersectExceptAll = val;
  • },
  • //Whether the dataset supports the IS TRUE syntax.
  • /**@ignore*/
  • supportsIsTrue:function(val){
  • -
  • 13168 this.__supportsIsTrue = val;
  • +
  • 13603 this.__supportsIsTrue = val;
  • },
  • //Whether the dataset supports the JOIN table USING (column1, ...) syntax.
  • /**@ignore*/
  • supportsJoinUsing:function(val){
  • -
  • 13170 this.__supportsJoinUsing = val;
  • +
  • 13605 this.__supportsJoinUsing = val;
  • },
  • //Whether modifying joined datasets is supported.
  • /**@ignore*/
  • supportsModifyingJoins:function(val){
  • -
  • 2292 this.__supportsModifyingJoins = val;
  • +
  • 2295 this.__supportsModifyingJoins = val;
  • },
  • //Whether the IN/NOT IN operators support multiple columns when an
  • /**@ignore*/
  • supportsMultipleColumnIn:function(val){
  • -
  • 13168 this.__supportsMultipleColumnIn = val;
  • +
  • 13603 this.__supportsMultipleColumnIn = val;
  • },
  • //Whether the dataset supports timezones in literal timestamps
  • /**@ignore*/
  • supportsTimestampTimezones:function(val){
  • -
  • 2291 this.__supportsTimestampTimezones = val;
  • +
  • 2294 this.__supportsTimestampTimezones = val;
  • },
  • //Whether the dataset supports fractional seconds in literal timestamps
  • /**@ignore*/
  • supportsTimestampUsecs:function(val){
  • -
  • 13168 this.__supportsTimestampUsecs = val;
  • +
  • 13603 this.__supportsTimestampUsecs = val;
  • },
  • //Whether the dataset supports window functions.
  • /**@ignore*/
  • supportsWindowFunctions:function(val){
  • -
  • 13168 this.__supportsWindowFunctions = val;
  • +
  • 13603 this.__supportsWindowFunctions = val;
  • }
  • }
  • diff --git a/docs/patio_Database.html b/docs/patio_Database.html index 796a82c8..9103a3be 100644 --- a/docs/patio_Database.html +++ b/docs/patio_Database.html @@ -6395,7 +6395,6 @@

    if (!isFunction(this.schemaParseTable)) { throw new Error("Schema parsing is not implemented on this database"); } - var ret = new Promise(); opts = opts || {}; var schemaParts = this.__schemaAndTable(table); var sch = schemaParts[0], tableName = schemaParts[1]; @@ -6404,26 +6403,21 @@

    if (opts.reload) { delete this.schemas[quotedName]; } - if (this.schemas[quotedName]) { - ret = this.schemas[quotedName]; - } else { - var self = this; - ret = this.schemas[quotedName] = this.schemaParseTable(tableName, opts).chain(function (cols) { - if (!cols || cols.length === 0) { - throw new Error("Error parsing schema, " + table + " no columns returns, table probably doesnt exist") - } else { - var schema = {}; - cols.forEach(function (c) { - var name = c[0]; - c = c[1]; - c.jsDefault = self.__columnSchemaToJsDefault(c["default"], c.type); - schema[name] = c; - }); - return schema; - } - }); - } - return ret.promise(); + var self = this; + return this.schemaParseTable(tableName, opts).chain(function (cols) { + if (!cols || cols.length === 0) { + throw new Error("Error parsing schema, " + table + " no columns returns, table probably doesnt exist") + } else { + var schema = {}; + cols.forEach(function (c) { + var name = c[0]; + c = c[1]; + c.jsDefault = self.__columnSchemaToJsDefault(c["default"], c.type); + schema[name] = c; + }); + return schema; + } + }); } diff --git a/docs/patio_Dataset.html b/docs/patio_Dataset.html index 02ce0514..7b81796e 100644 --- a/docs/patio_Dataset.html +++ b/docs/patio_Dataset.html @@ -3689,7 +3689,7 @@

    throw new QueryError("Between requires an array for the value"); } } - var ret = pairs.length == 1 ? pairs[0] : BooleanExpression.fromArgs(["AND"].concat(pairs)) + var ret = pairs.length === 1 ? pairs[0] : BooleanExpression.fromArgs(["AND"].concat(pairs)); return invert ? BooleanExpression.invert(ret) : ret; } @@ -3760,7 +3760,7 @@

    pairs.push(new BooleanExpression(op, new Identifier(pair[0]), pair[1])); }); } - return pairs.length == 1 ? pairs[0] : BooleanExpression.fromArgs(["AND"].concat(pairs)); + return pairs.length === 1 ? pairs[0] : BooleanExpression.fromArgs(["AND"].concat(pairs)); } @@ -4025,7 +4025,7 @@

    clause = (tOpts.having ? "having" : "where"), clauseObj = tOpts[clause]; var args = argsToArray(arguments, 2); - args = args.length == 1 ? args[0] : args; + args = args.length === 1 ? args[0] : args; var opts = {}; if (clauseObj) { addedByBool = isUndefined(addedByBool) ? "AND" : addedByBool; @@ -4253,8 +4253,8 @@

    if (cond.length && isFunction(cond[cond.length - 1])) { cb = cond.pop(); } - cond = cond.length == 1 ? cond[0] : cond - if ((cond == null || cond == undefined || cond === "") || (isArray(cond) && cond.length == 0 && !cb) || (isObject(cond) && isEmpty(cond) && !cb)) { + cond = cond.length === 1 ? cond[0] : cond; + if ((cond == null || cond === undefined || cond === "") || (isArray(cond) && cond.length === 0 && !cb) || (isObject(cond) && isEmpty(cond) && !cb)) { return this.mergeOptions(); } else { cond = this._filterExpr(cond, cb); @@ -4309,9 +4309,9 @@

    function (expr,cb,joinCond){ expr = (isUndefined(expr) || isNull(expr) || (isArray(expr) && !expr.length)) ? null : expr; if (expr && cb) { - return new BooleanExpression(joinCond || "AND", this._filterExpr(expr, null, joinCond), this._filterExpr(cb, null, joinCond)) + return new BooleanExpression(joinCond || "AND", this._filterExpr(expr, null, joinCond), this._filterExpr(cb, null, joinCond)); } else if (cb) { - expr = cb + expr = cb; } if (isInstanceOf(expr, Expression)) { if (isInstanceOf(expr, NumericExpression, StringExpression)) { @@ -4324,7 +4324,7 @@

    if (isString(first)) { return new PlaceHolderLiteralString(first, expr.slice(1), true); } else if (Expression.isConditionSpecifier(expr)) { - return BooleanExpression.fromValuePairs(expr, joinCond) + return BooleanExpression.fromValuePairs(expr, joinCond); } else { return BooleanExpression.fromArgs([joinCond || "AND"].concat(expr.map(function (e) { return this._filterExpr(e, null, joinCond); @@ -7875,7 +7875,7 @@

    cond = this._filterExpr.call(this, cond); cond = BooleanExpression.invert(cond); if (clauseObj) { - cond = new BooleanExpression("AND", clauseObj, cond) + cond = new BooleanExpression("AND", clauseObj, cond); } var opts = {}; opts[clause] = cond; @@ -8541,16 +8541,16 @@

    sources.push(new AliasedExpression(new Identifier(i), s[i])); } } else if (isString(s)) { - sources.push(this.stringToIdentifier(s)) + sources.push(this.stringToIdentifier(s)); } else { sources.push(s); } }, this); - var o = {from: sources.length ? sources : null} + var o = {from: sources.length ? sources : null}; if (tableAliasNum) { o.numDatasetSources = tableAliasNum; } - return this.mergeOptions(o) + return this.mergeOptions(o); } @@ -8622,7 +8622,7 @@

    var fs = {}; var nonSqlOptions = this._static.NON_SQL_OPTIONS; Object.keys(this.__opts).forEach(function (k) { - if (nonSqlOptions.indexOf(k) == -1) { + if (nonSqlOptions.indexOf(k) === -1) { fs[k] = null; } }); @@ -9244,7 +9244,7 @@

    function (columns){ columns = argsToArray(arguments); var self = this; - return this.mergeOptions({group: (array.compact(columns).length == 0 ? null : columns.map(function (c) { + return this.mergeOptions({group: (array.compact(columns).length === 0 ? null : columns.map(function (c) { return isString(c) ? self.stringToIdentifier(c) : c; }))}); @@ -9529,7 +9529,7 @@

     function (){
        var cond = argsToArray(arguments).map(function (s) {
    -       return isString(s) && s !== '' ? this.stringToIdentifier(s) : s
    +       return isString(s) && s !== '' ? this.stringToIdentifier(s) : s;
        }, this);
        return this._filter.apply(this, ["having"].concat(cond));
                
    @@ -10240,7 +10240,7 @@ 

    if (!(having || where)) { throw new QueryError("No current filter"); } - var o = {} + var o = {}; if (having) { o.having = BooleanExpression.invert(having); } @@ -11093,7 +11093,7 @@

    expr = isUndefined(expr) ? null : expr, options = isUndefined(options) ? {} : options; var h; var usingJoin = isArray(expr) && expr.length && expr.every(function (x) { - return isString(x) || isInstanceOf(x, Identifier) + return isString(x) || isInstanceOf(x, Identifier); }); if (usingJoin && !this.supportsJoinUsing) { h = {}; @@ -11128,7 +11128,7 @@

    } else { table = isString(table) ? this.stringToIdentifier(table) : table; var parts = this._splitAlias(table), implicitTableAlias = parts[1]; - table = parts[0] + table = parts[0]; tableAlias = tableAlias || implicitTableAlias; tableName = tableAlias || table; } @@ -11147,7 +11147,7 @@

    var newExpr = []; for (var i in expr) { var val = expr[i]; - if (isArray(val) && val.length == 2) { + if (isArray(val) && val.length === 2) { i = val[0], val = val[1]; } var k = this.qualifiedColumnName(i, tableName), v; @@ -11400,7 +11400,7 @@

    if (this.__opts.sql) { return this.fromSelf().limit(limit, offset); } - if (isArray(limit) && limit.length == 2) { + if (isArray(limit) && limit.length === 2) { offset = limit[0]; limit = limit[1] - limit[0] + 1; } @@ -12484,7 +12484,7 @@

    var clause = (tOpts.having ? "having" : "where"), clauseObj = tOpts[clause]; if (clauseObj) { var args = argsToArray(arguments); - args = args.length == 1 ? args[0] : args; + args = args.length === 1 ? args[0] : args; var opts = {}; opts[clause] = new BooleanExpression("OR", clauseObj, this._filterExpr(args)); return this.mergeOptions(opts); @@ -12565,7 +12565,7 @@

    return this.or.apply(this, arguments); } else { var args = argsToArray(arguments); - args = args.length == 1 ? args[0] : args; + args = args.length === 1 ? args[0] : args; var opts = {}; opts[clause] = this._filterExpr(args, null, "AND"); return this.mergeOptions(opts); @@ -16078,7 +16078,7 @@

    throw new QueryError("This dataset does not support common table expressions"); } opts = opts || {}; - var wit = (this.__opts["with"] || []).concat([merge(opts, {recursive: true, name: this.stringToIdentifier(name), dataset: nonRecursive.union(recursive, {all: opts.unionAll != false, fromSelf: false})})]); + var wit = (this.__opts["with"] || []).concat([merge(opts, {recursive: true, name: this.stringToIdentifier(name), dataset: nonRecursive.union(recursive, {all: opts.unionAll !== false, fromSelf: false})})]); return this.mergeOptions({"with": wit}); } @@ -16141,7 +16141,7 @@

    function (sql){ var args = argsToArray(arguments).slice(1); if (args.length) { - sql = new PlaceHolderLiteralString(sql, args) + sql = new PlaceHolderLiteralString(sql, args); } return this.mergeOptions({sql: sql}); diff --git a/docs/patio_sql.html b/docs/patio_sql.html index 8a26e9f7..6a286ed6 100644 --- a/docs/patio_sql.html +++ b/docs/patio_sql.html @@ -554,129 +554,6 @@ - - Source -
    -{
    -    /**@lends patio.sql*/
    -    /**
    -     * Returns a {@link patio.sql.Identifier}, {@link patio.sql.QualifiedIdentifier},
    -     * or {@link patio.sql.ALiasedExpression} depending on the format of the string
    -     * passed in.
    -     *
    -     * &lt;ul>
    -     *      &lt;li>For columns : table__column___alias.&lt;/li>
    -     *      &lt;li>For tables : schema__table___alias.&lt;/li>
    -     * &lt;/ul>
    -     * each portion of the identifier is optional. See example below
    -     *
    -     * @example
    -     *
    -     * patio.sql.identifier("a") //= > new patio.sql.Identifier("a");
    -     * patio.sql.identifier("table__column"); //=> new patio.sql.QualifiedIdentifier(table, column);
    -     * patio.sql.identifier("table__column___alias");
    -     *      //=> new patio.sql.AliasedExpression(new patio.sql.QualifiedIdentifier(table, column), alias);
    -     *
    -     * @param {String} name the name to covert to an an {@link patio.sql.Identifier}, {@link patio.sql.QualifiedIdentifier},
    -     * or {@link patio.sql.AliasedExpression}.
    -     *
    -     * @return  {patio.sql.Identifier|patio.sql.QualifiedIdentifier|patio.sql.AliasedExpression} an identifier generated based on the name string.
    -     */
    -    identifier:function (s) {
    -        return sql.stringToIdentifier(s);
    -    },
    -    /**
    -     * @see patio.sql.identifier
    -     */
    -    stringToIdentifier:function (name) {
    -        !Dataset && (Dataset = require("./dataset"));
    -        return new Dataset().stringToIdentifier(name);
    -    },
    -    /**
    -     * Creates a {@link patio.sql.LiteralString} or {@link patio.sql.PlaceHolderLiteralString}
    -     * depending on the arguments passed in. If a single string is passed in then
    -     * it is assumed to be a {@link patio.sql.LiteralString}. If more than one argument is
    -     * passed in then it is assumed to be a {@link patio.sql.PlaceHolderLiteralString}.
    -     *
    -     * @example
    -     *
    -     * //a literal string that will be placed in an SQL query with out quoting.
    -     * patio.sql.literal("a"); //=> new patio.sql.LiteralString('a');
    -     *
    -     * //a placeholder string that will have ? replaced with the {@link patio.Dataset#literal} version of
    -     * //the arugment and replaced in the string.
    -     * patio.sql.literal("a = ?", 1)  //=> a = 1
    -     * patio.sql.literal("a = ?", "b"); //=> a = 'b'
    -     * patio.sql.literal("a = {a} AND b = {b}", {a : 1, b : 2}); //=> a = 1 AND b = 2
    -     *
    -     * @param {String ...} s variable number of arguments where the first argument
    -     * is a string. If multiple arguments are passed it is a assumed to be a {@link patio.sql.PlaceHolderLiteralString}
    -     *
    -     * @return {patio.sql.LiteralString|patio.sql.PlaceHolderLiteralString} an expression that can be used as an argument
    -     * for {@link patio.Dataset} query methods.
    -     */
    -    literal:function (s) {
    -        var args = argsToArray(arguments);
    -        return args.length > 1 ? PlaceHolderLiteralString.fromArgs(args) : new LiteralString(s);
    -    },
    -    /**
    -     * Returns a {@link patio.sql.CaseExpression}. See {@link patio.sql.CaseExpression} for argument types.
    -     *
    -     * @example
    -     *
    -     * sql["case"]({a:sql.b}, sql.c, sql.d); //=> (CASE t.d WHEN t.a THEN t.b ELSE t.c END)
    -     *
    -     */
    -    "case":function (hash, /*args**/opts) {
    -        var args = argsToArray(arguments, 1);
    -        return CaseExpression.fromArgs([hashToArray(hash)].concat(args));
    -    },
    -    /**
    -     * Creates a {@link patio.sql.StringExpression}
    -     *
    -     * Return a {@link patio.sql.StringExpression} representing an SQL string made up of the
    -     * concatenation of this array's elements.  If an joiner is passed
    -     * it is used in between each element of the array in the SQL
    -     * concatenation.
    -     *
    -     * @example
    -     *   patio.sql.sqlStringJoin(["a"]); //=> a
    -     *   //you can use sql.* as a shortcut to get an identifier
    -     *   patio.sql.sqlStringJoin([sql.identifier("a"), sql.b]);//=> a || b
    -     *   patio.sql.sqlStringJoin([sql.a, 'b']) # SQL: a || 'b'
    -     *   patio.sql.sqlStringJoin(['a', sql.b], ' '); //=> 'a' || ' ' || b
    -     */
    -    sqlStringJoin:function (arr, joiner) {
    -        joiner = joiner || null;
    -        var args;
    -        arr = arr.map(function (a) {
    -            return isInstanceOf(a, Expression, LiteralString, Boolean) || isNull(a) ? a : sql.stringToIdentifier(a)
    -        });
    -        if (joiner) {
    -            var newJoiner = [];
    -            for (var i = 0; i &lt; arr.length; i++) {
    -                newJoiner.push(joiner);
    -            }
    -            args = array.flatten(array.zip(arr, newJoiner));
    -            args.pop();
    -        } else {
    -            args = arr;
    -        }
    -        args = args.map(function (a) {
    -            return isInstanceOf(a, Expression, LiteralString, Boolean) || isNull(a) ? a : "" + a;
    -        });
    -        return StringExpression.fromArgs(["||"].concat(args));
    -    },
    -    Year:Year,
    -    TimeStamp:TimeStamp,
    -    Time:Time,
    -    DateTime:DateTime,
    -    Float:Float,
    -    Decimal:Decimal
    -}
    -    
    - -
    PropertyTypeDefault ValueDescription
    NegativeBooleanConstantdeclarationdefine(BooleanConstant, {

    Represents inverse boolean constants (currently only NOTNULL). A special class to allow for special behavior.

    @@ -931,7 +808,7 @@

    joiner = joiner || null; var args; arr = arr.map(function (a) { - return isInstanceOf(a, Expression, LiteralString, Boolean) || isNull(a) ? a : sql.stringToIdentifier(a) + return isInstanceOf(a, Expression, LiteralString, Boolean) || isNull(a) ? a : sql.stringToIdentifier(a); }); if (joiner) { var newJoiner = []; diff --git a/docs/patio_sql_BooleanExpression.html b/docs/patio_sql_BooleanExpression.html index 0ed2fea8..4e059817 100644 --- a/docs/patio_sql_BooleanExpression.html +++ b/docs/patio_sql_BooleanExpression.html @@ -472,13 +472,6 @@

    Constructor

    - - Source -
    -define([ComplexExpression, BooleanMethods], {
    -            
    - - @@ -522,6 +515,8 @@

  • [key= null] :

    the key that the hash corresponds to

  • +
  • op :
  • + @@ -538,13 +533,13 @@

    Source
    -function (expr,key){
    +function (expr,key,op){
        var pairs = [], opts, newKey;
        var twoArityOperators = this.TWO_ARITY_OPERATORS;
        for (var k in expr) {
            var v = expr[k];
            if (isHash(v)) { //its a hash too filter it too!
    -           pairs.push(this.__filterObject(v, k));
    +           pairs.push(this.__filterObject(v, k, op));
            } else if (key && (twoArityOperators[k.toUpperCase()] || k.match(/between/i))) {
                //its a two arrity operator (e.g. '=', '>')
                newKey = isString(key) ? key.split(",") : [key];
    @@ -553,7 +548,7 @@ 

    //(e.g. {"col1,col2" : 1}) => WHERE (col1 = 1 AND col2 = 1) pairs = pairs.concat(newKey.map(function (k) { //filter each column with the expression - return this.__filterObject(expr, k); + return this.__filterObject(expr, k, op); }, this)); } else { newKey = [sql.stringToIdentifier(newKey[0])]; @@ -562,7 +557,7 @@

    pairs.push(StringExpression.like.apply(StringExpression, (newKey.concat(isArray(v) ? v : [v])))); } else if (k.match(/^iLike$/)) { //its a like clause {col : {iLike : "hello"}} - pairs.push(StringExpression.like.apply(StringExpression, (newKey.concat(isArray(v) ? v : [v]).concat({caseInsensitive:true})))); + pairs.push(StringExpression.like.apply(StringExpression, (newKey.concat(isArray(v) ? v : [v]).concat({caseInsensitive: true})))); } else if (k.match(/between/i)) { //its a like clause {col : {between : [1,10]}} var between = sql.stringToIdentifier(newKey[0]).between(v); @@ -590,7 +585,7 @@

    } //if the total of pairs is one then we just return the first element //otherwise we join them all with an AND - return pairs.length == 1 ? pairs[0] : BooleanExpression.fromArgs(["AND"].concat(pairs)); + return pairs.length == 1 ? pairs[0] : BooleanExpression.fromArgs([op || "AND"].concat(pairs)); }

    @@ -675,14 +670,14 @@

    var pairArr = []; var isArr = isArray(a) && Expression.isConditionSpecifier(a); if (isHash(a)) { - pairArr.push(this.__filterObject(a)); + pairArr.push(this.__filterObject(a, null, op)); } else { for (var k in a) { var v = isArr ? a[k][1] : a[k], ret; k = isArr ? a[k][0] : k; if (isArray(v) || isInstanceOf(v, Dataset)) { k = isArray(k) ? k.map(function (i) { - return isString(i) ? sql.stringToIdentifier(i) : i + return isString(i) ? sql.stringToIdentifier(i) : i; }) : isString(k) ? sql.stringToIdentifier(k) : k; ret = new BooleanExpression("IN", k, v); } else if (isInstanceOf(v, NegativeBooleanConstant)) { @@ -692,7 +687,7 @@

    } else if (isNull(v) || isBoolean(v)) { ret = new BooleanExpression("IS", k, v); } else if (isHash(v)) { - ret = BooleanExpression.__filterObject(v, k); + ret = BooleanExpression.__filterObject(v, k, op); } else if (isRegExp(v)) { ret = StringExpression.like(sql.stringToIdentifier(k), v); } else { @@ -767,7 +762,7 @@

    function (expression){ if (isInstanceOf(expression, BooleanExpression)) { var op = expression.op, newArgs; - if (op == "AND" || op == "OR") { + if (op === "AND" || op === "OR") { newArgs = [OPERTATOR_INVERSIONS[op]].concat(expression.args.map(function (arg) { return BooleanExpression.invert(arg); })); diff --git a/docs/patio_sql_ComplexExpression.html b/docs/patio_sql_ComplexExpression.html index 7c90213f..6c10ac5c 100644 --- a/docs/patio_sql_ComplexExpression.html +++ b/docs/patio_sql_ComplexExpression.html @@ -561,7 +561,7 @@

    Constructor

     function (op){
        if (op) {
    -       var args = argsToArray(arguments,1 );
    +       var args = argsToArray(arguments, 1);
            //make a copy of the args
            var origArgs = args.slice(0);
            args.forEach(function (a, i) {
    @@ -572,25 +572,25 @@ 

    Constructor

    op = op.toUpperCase(); if (N_ARITY_OPERATORS.hasOwnProperty(op)) { if (args.length &lt; 1) { - throw new ExpressionError("The " + op + " operator requires at least 1 argument") + throw new ExpressionError("The " + op + " operator requires at least 1 argument"); } var oldArgs = args.slice(0); args = []; oldArgs.forEach(function (a) { - a instanceof ComplexExpression && a.op == op ? args = args.concat(a.args) : args.push(a); + a instanceof ComplexExpression && a.op === op ? args = args.concat(a.args) : args.push(a); }); } else if (TWO_ARITY_OPERATORS.hasOwnProperty(op)) { - if (args.length != 2) { + if (args.length !== 2) { throw new ExpressionError("The " + op + " operator requires precisely 2 arguments"); } //With IN/NOT IN, even if the second argument is an array of two element arrays, //don't convert it into a boolean expression, since it's definitely being used //as a value list. if (IN_OPERATORS[op]) { - args[1] = origArgs[1] + args[1] = origArgs[1]; } } else if (ONE_ARITY_OPERATORS.hasOwnProperty(op)) { - if (args.length != 1) { + if (args.length !== 1) { throw new ExpressionError("The " + op + " operator requires only one argument"); } } else { diff --git a/docs/patio_sql_Constants.html b/docs/patio_sql_Constants.html index 0badefc9..ae37584b 100644 --- a/docs/patio_sql_Constants.html +++ b/docs/patio_sql_Constants.html @@ -404,47 +404,47 @@ * Constant for CURRENT DATE * @type patio.sql.Constant */ - CURRENT_DATE:new Constant("CURRENT_DATE"), + CURRENT_DATE: new Constant("CURRENT_DATE"), /** * Constant for CURRENT TIME * @type patio.sql.Constant */ - CURRENT_TIME:new Constant("CURRENT_TIME"), + CURRENT_TIME: new Constant("CURRENT_TIME"), /** * Constant for CURRENT TIMESTAMP * @type patio.sql.Constant */ - CURRENT_TIMESTAMP:new Constant("CURRENT_TIMESTAMP"), + CURRENT_TIMESTAMP: new Constant("CURRENT_TIMESTAMP"), /** * Constant for TRUE * @type patio.sql.BooleanConstant */ - SQLTRUE:new BooleanConstant(1), + SQLTRUE: new BooleanConstant(1), /** * Constant for TRUE * @type patio.sql.BooleanConstant */ - TRUE:new BooleanConstant(1), + TRUE: new BooleanConstant(1), /** * Constant for FALSE. * @type patio.sql.BooleanConstant */ - SQLFALSE:new BooleanConstant(0), + SQLFALSE: new BooleanConstant(0), /** * Constant for FALSE * @type patio.sql.BooleanConstant */ - FALSE:new BooleanConstant(0), + FALSE: new BooleanConstant(0), /** * Constant for NULL * @type patio.sql.BooleanConstant */ - NULL:new BooleanConstant(null), + NULL: new BooleanConstant(null), /** * Constant for NOT NULL * @type patio.sql.NegativeBooleanConstant */ - NOTNULL:new NegativeBooleanConstant(null) + NOTNULL: new NegativeBooleanConstant(null) }
    diff --git a/docs/patio_sql_DateTime.html b/docs/patio_sql_DateTime.html index 2162c62a..e2c5eaa9 100644 --- a/docs/patio_sql_DateTime.html +++ b/docs/patio_sql_DateTime.html @@ -421,9 +421,9 @@

    Constructor

     function (y,m,d,h,min,s,ms){
        var args = argsToArray(arguments);
    -   if(args.length === 0){
    +   if (args.length === 0) {
            this.date = new Date();
    -   }else if (isDate(y)) {
    +   } else if (isDate(y)) {
            this.date = y;
        } else {
            var date = new Date(1970, 0, 1, 0, 0, 0);
    diff --git a/docs/patio_sql_Expression.html b/docs/patio_sql_Expression.html
    index 96ff841e..e763e87f 100644
    --- a/docs/patio_sql_Expression.html
    +++ b/docs/patio_sql_Expression.html
    @@ -471,13 +471,6 @@ 

    Constructor

    - - Source -
    -define(null, {
    -            
    - - @@ -531,9 +524,9 @@

    Source
     function (args){
    -   var ret;
    +   var ret, Self = this;
        try {
    -       ret = new this();
    +       ret = new Self();
        } catch (ignore) {
        }
        this.apply(ret, args);
    diff --git a/docs/patio_sql_InequalityMethods.html b/docs/patio_sql_InequalityMethods.html
    index 9174616c..abe746f5 100644
    --- a/docs/patio_sql_InequalityMethods.html
    +++ b/docs/patio_sql_InequalityMethods.html
    @@ -568,7 +568,7 @@ 

    Source
     function (items){
    -   return new BooleanExpression("AND", new BooleanExpression("gte", this, items[0]), new BooleanExpression("lte", this, items[1]))
    +   return new BooleanExpression("AND", new BooleanExpression("gte", this, items[0]), new BooleanExpression("lte", this, items[1]));
                
     }
         
    diff --git a/docs/patio_sql_OrderedExpression.html b/docs/patio_sql_OrderedExpression.html index 492d433d..37bebc58 100644 --- a/docs/patio_sql_OrderedExpression.html +++ b/docs/patio_sql_OrderedExpression.html @@ -554,7 +554,7 @@

    Source
     function (){
    -   return new OrderedExpression(this.__expression, false, {nulls:this.__nulls});
    +   return new OrderedExpression(this.__expression, false, {nulls: this.__nulls});
                
     }
         
    @@ -597,7 +597,7 @@

    Source
     function (){
    -   return new OrderedExpression(this.__expression, true, {nulls:this.__nulls});
    +   return new OrderedExpression(this.__expression, true, {nulls: this.__nulls});
                
     }
         
    @@ -641,7 +641,7 @@

    Source
     function (){
    -   return new OrderedExpression(this.__expression, !this.__descending, {nulls:this._static.INVERT_NULLS[this.__nulls] || this.__nulls});
    +   return new OrderedExpression(this.__expression, !this.__descending, {nulls: this._static.INVERT_NULLS[this.__nulls] || this.__nulls});
                
     }
         
    diff --git a/docs/patio_sql_StringExpression.html b/docs/patio_sql_StringExpression.html index 08b2fde6..7424a6a7 100644 --- a/docs/patio_sql_StringExpression.html +++ b/docs/patio_sql_StringExpression.html @@ -445,7 +445,7 @@ Static Properties -
    PropertyTypeDefault ValueDescription
    likeMapObject{"truetrue":'~*', "truefalse":"~", "falsetrue":"ILIKE", "falsefalse":"LIKE"}

    Like map used to by patio.sql.StringExpression.like to create the +
    PropertyTypeDefault ValueDescription
    likeMapObject{"truetrue": '~*', "truefalse": "~", "falsetrue": "ILIKE", "falsefalse": "LIKE"}

    Like map used to by patio.sql.StringExpression.like to create the LIKE expression.

    diff --git a/docs/patio_sql_StringMethods.html b/docs/patio_sql_StringMethods.html index e1689656..abd8cc50 100644 --- a/docs/patio_sql_StringMethods.html +++ b/docs/patio_sql_StringMethods.html @@ -514,7 +514,7 @@

    function (expression){ expression = argsToArray(arguments); return StringExpression.like.apply(StringExpression, [this].concat(expression).concat([ - {caseInsensitive:true} + {caseInsensitive: true} ])); } diff --git a/lib/database/query.js b/lib/database/query.js index 1548e80b..aecf620f 100755 --- a/lib/database/query.js +++ b/lib/database/query.js @@ -282,7 +282,6 @@ var Database = define(null, { if (!isFunction(this.schemaParseTable)) { throw new Error("Schema parsing is not implemented on this database"); } - var ret = new Promise(); opts = opts || {}; var schemaParts = this.__schemaAndTable(table); var sch = schemaParts[0], tableName = schemaParts[1]; @@ -291,26 +290,21 @@ var Database = define(null, { if (opts.reload) { delete this.schemas[quotedName]; } - if (this.schemas[quotedName]) { - ret = this.schemas[quotedName]; - } else { - var self = this; - ret = this.schemas[quotedName] = this.schemaParseTable(tableName, opts).chain(function (cols) { - if (!cols || cols.length === 0) { - throw new Error("Error parsing schema, " + table + " no columns returns, table probably doesnt exist") - } else { - var schema = {}; - cols.forEach(function (c) { - var name = c[0]; - c = c[1]; - c.jsDefault = self.__columnSchemaToJsDefault(c["default"], c.type); - schema[name] = c; - }); - return schema; - } - }); - } - return ret.promise(); + var self = this; + return this.schemaParseTable(tableName, opts).chain(function (cols) { + if (!cols || cols.length === 0) { + throw new Error("Error parsing schema, " + table + " no columns returns, table probably doesnt exist") + } else { + var schema = {}; + cols.forEach(function (c) { + var name = c[0]; + c = c[1]; + c.jsDefault = self.__columnSchemaToJsDefault(c["default"], c.type); + schema[name] = c; + }); + return schema; + } + }); }, /** diff --git a/lib/dataset/query.js b/lib/dataset/query.js index 4622a6a0..ae96cf49 100755 --- a/lib/dataset/query.js +++ b/lib/dataset/query.js @@ -152,7 +152,7 @@ define(null, { var clause = (tOpts.having ? "having" : "where"), clauseObj = tOpts[clause]; if (clauseObj) { var args = argsToArray(arguments); - args = args.length == 1 ? args[0] : args; + args = args.length === 1 ? args[0] : args; var opts = {}; opts[clause] = new BooleanExpression("OR", clauseObj, this._filterExpr(args)); return this.mergeOptions(opts); @@ -261,7 +261,7 @@ define(null, { return this.or.apply(this, arguments); } else { var args = argsToArray(arguments); - args = args.length == 1 ? args[0] : args; + args = args.length === 1 ? args[0] : args; var opts = {}; opts[clause] = this._filterExpr(args, null, "AND"); return this.mergeOptions(opts); @@ -391,7 +391,7 @@ define(null, { cond = this._filterExpr.call(this, cond); cond = BooleanExpression.invert(cond); if (clauseObj) { - cond = new BooleanExpression("AND", clauseObj, cond) + cond = new BooleanExpression("AND", clauseObj, cond); } var opts = {}; opts[clause] = cond; @@ -526,17 +526,17 @@ define(null, { sources.push(new AliasedExpression(new Identifier(i), s[i])); } } else if (isString(s)) { - sources.push(this.stringToIdentifier(s)) + sources.push(this.stringToIdentifier(s)); } else { sources.push(s); } }, this); - var o = {from: sources.length ? sources : null} + var o = {from: sources.length ? sources : null}; if (tableAliasNum) { o.numDatasetSources = tableAliasNum; } - return this.mergeOptions(o) + return this.mergeOptions(o); }, /** @@ -564,7 +564,7 @@ define(null, { var fs = {}; var nonSqlOptions = this._static.NON_SQL_OPTIONS; Object.keys(this.__opts).forEach(function (k) { - if (nonSqlOptions.indexOf(k) == -1) { + if (nonSqlOptions.indexOf(k) === -1) { fs[k] = null; } }); @@ -652,7 +652,7 @@ define(null, { group: function (columns) { columns = argsToArray(arguments); var self = this; - return this.mergeOptions({group: (array.compact(columns).length == 0 ? null : columns.map(function (c) { + return this.mergeOptions({group: (array.compact(columns).length === 0 ? null : columns.map(function (c) { return isString(c) ? self.stringToIdentifier(c) : c; }))}); }, @@ -706,7 +706,7 @@ define(null, { **/ having: function () { var cond = argsToArray(arguments).map(function (s) { - return isString(s) && s !== '' ? this.stringToIdentifier(s) : s + return isString(s) && s !== '' ? this.stringToIdentifier(s) : s; }, this); return this._filter.apply(this, ["having"].concat(cond)); }, @@ -767,7 +767,7 @@ define(null, { if (!(having || where)) { throw new QueryError("No current filter"); } - var o = {} + var o = {}; if (having) { o.having = BooleanExpression.invert(having); } @@ -901,7 +901,7 @@ define(null, { var h; var usingJoin = isArray(expr) && expr.length && expr.every(function (x) { - return isString(x) || isInstanceOf(x, Identifier) + return isString(x) || isInstanceOf(x, Identifier); }); if (usingJoin && !this.supportsJoinUsing) { h = {}; @@ -936,7 +936,7 @@ define(null, { } else { table = isString(table) ? this.stringToIdentifier(table) : table; var parts = this._splitAlias(table), implicitTableAlias = parts[1]; - table = parts[0] + table = parts[0]; tableAlias = tableAlias || implicitTableAlias; tableName = tableAlias || table; } @@ -955,7 +955,7 @@ define(null, { var newExpr = []; for (var i in expr) { var val = expr[i]; - if (isArray(val) && val.length == 2) { + if (isArray(val) && val.length === 2) { i = val[0], val = val[1]; } var k = this.qualifiedColumnName(i, tableName), v; @@ -1010,7 +1010,7 @@ define(null, { if (this.__opts.sql) { return this.fromSelf().limit(limit, offset); } - if (isArray(limit) && limit.length == 2) { + if (isArray(limit) && limit.length === 2) { offset = limit[0]; limit = limit[1] - limit[0] + 1; } @@ -1941,7 +1941,7 @@ define(null, { throw new QueryError("This dataset does not support common table expressions"); } opts = opts || {}; - var wit = (this.__opts["with"] || []).concat([merge(opts, {recursive: true, name: this.stringToIdentifier(name), dataset: nonRecursive.union(recursive, {all: opts.unionAll != false, fromSelf: false})})]); + var wit = (this.__opts["with"] || []).concat([merge(opts, {recursive: true, name: this.stringToIdentifier(name), dataset: nonRecursive.union(recursive, {all: opts.unionAll !== false, fromSelf: false})})]); return this.mergeOptions({"with": wit}); }, @@ -1961,7 +1961,7 @@ define(null, { withSql: function (sql) { var args = argsToArray(arguments).slice(1); if (args.length) { - sql = new PlaceHolderLiteralString(sql, args) + sql = new PlaceHolderLiteralString(sql, args); } return this.mergeOptions({sql: sql}); }, @@ -2044,7 +2044,7 @@ define(null, { clause = (tOpts.having ? "having" : "where"), clauseObj = tOpts[clause]; var args = argsToArray(arguments, 2); - args = args.length == 1 ? args[0] : args; + args = args.length === 1 ? args[0] : args; var opts = {}; if (clauseObj) { addedByBool = isUndefined(addedByBool) ? "AND" : addedByBool; @@ -2066,8 +2066,8 @@ define(null, { if (cond.length && isFunction(cond[cond.length - 1])) { cb = cond.pop(); } - cond = cond.length == 1 ? cond[0] : cond - if ((cond == null || cond == undefined || cond === "") || (isArray(cond) && cond.length == 0 && !cb) || (isObject(cond) && isEmpty(cond) && !cb)) { + cond = cond.length === 1 ? cond[0] : cond; + if ((cond == null || cond === undefined || cond === "") || (isArray(cond) && cond.length === 0 && !cb) || (isObject(cond) && isEmpty(cond) && !cb)) { return this.mergeOptions(); } else { cond = this._filterExpr(cond, cb); @@ -2151,7 +2151,7 @@ define(null, { pairs.push(new BooleanExpression(op, new Identifier(pair[0]), pair[1])); }); } - return pairs.length == 1 ? pairs[0] : BooleanExpression.fromArgs(["AND"].concat(pairs)); + return pairs.length === 1 ? pairs[0] : BooleanExpression.fromArgs(["AND"].concat(pairs)); }, /** @@ -2180,7 +2180,7 @@ define(null, { throw new QueryError("Between requires an array for the value"); } } - var ret = pairs.length == 1 ? pairs[0] : BooleanExpression.fromArgs(["AND"].concat(pairs)) + var ret = pairs.length === 1 ? pairs[0] : BooleanExpression.fromArgs(["AND"].concat(pairs)); return invert ? BooleanExpression.invert(ret) : ret; }, @@ -2220,9 +2220,9 @@ define(null, { _filterExpr: function (expr, cb, joinCond) { expr = (isUndefined(expr) || isNull(expr) || (isArray(expr) && !expr.length)) ? null : expr; if (expr && cb) { - return new BooleanExpression(joinCond || "AND", this._filterExpr(expr, null, joinCond), this._filterExpr(cb, null, joinCond)) + return new BooleanExpression(joinCond || "AND", this._filterExpr(expr, null, joinCond), this._filterExpr(cb, null, joinCond)); } else if (cb) { - expr = cb + expr = cb; } if (isInstanceOf(expr, Expression)) { if (isInstanceOf(expr, NumericExpression, StringExpression)) { @@ -2235,7 +2235,7 @@ define(null, { if (isString(first)) { return new PlaceHolderLiteralString(first, expr.slice(1), true); } else if (Expression.isConditionSpecifier(expr)) { - return BooleanExpression.fromValuePairs(expr, joinCond) + return BooleanExpression.fromValuePairs(expr, joinCond); } else { return BooleanExpression.fromArgs([joinCond || "AND"].concat(expr.map(function (e) { return this._filterExpr(e, null, joinCond); @@ -2268,13 +2268,13 @@ define(null, { isSimpleSelectAll: function () { var o = {}, opts = this.__opts, count = 0; for (var i in opts) { - if (opts[i] != null && this._static.NON_SQL_OPTIONS.indexOf(i) == -1) { + if (opts[i] != null && this._static.NON_SQL_OPTIONS.indexOf(i) === -1) { o[i] = opts[i]; count++; } } - var f = o.from - return count == 1 && f.length == 1 && (isString(f[0]) || isInstanceOf(f[0], AliasedExpression, Identifier)); + var f = o.from; + return count === 1 && f.length === 1 && (isString(f[0]) || isInstanceOf(f[0], AliasedExpression, Identifier)); } } }, @@ -2345,5 +2345,4 @@ define(null, { this.QUERY_METHODS = queryMethods.concat(joinMethods); } } -}). - as(module); +}).as(module); diff --git a/lib/sql.js b/lib/sql.js index 8fcfb4aa..45f545a3 100755 --- a/lib/sql.js +++ b/lib/sql.js @@ -20,13 +20,11 @@ var comb = require("comb-proxy"), isString = comb.isString, define = comb.define, isRegExp = comb.isRegExp, - Dataset, patio; + Dataset, patio, sql, Expression, AliasedExpression, CaseExpression, Cast, + ColumnAll, BooleanExpression; var virtualRow = function (name) { - var WILDCARD = new LiteralString('*'); - var QUESTION_MARK = new LiteralString('?'); - var COMMA_SEPARATOR = new LiteralString(', '); var DOUBLE_UNDERSCORE = '__'; var parts = name.split(DOUBLE_UNDERSCORE); @@ -36,7 +34,7 @@ var virtualRow = function (name) { return function () { var args = argsToArray(arguments); return SQLFunction.fromArgs([m, name].concat(args)); - } + }; }, column ? QualifiedIdentifier : Identifier); var ret = createFunctionWrapper(prox, function (m) { var args = argsToArray(arguments); @@ -48,7 +46,7 @@ var virtualRow = function (name) { }, function () { return SQLFunction.fromArgs(arguments); }); - ret.__proto__ = ident; + ret["__proto__"] = ident; return ret; }; @@ -62,7 +60,7 @@ var DATE_METHODS = ["getDate", "getDay", "getFullYear", "getHours", "getMillisec var addDateMethod = function (op) { return function () { return this.date[op].apply(this.date, arguments); - } + }; }; /** @@ -219,9 +217,9 @@ DATE_METHODS.forEach(function (op) { */ var DateTime = function (y, m, d, h, min, s, ms) { var args = argsToArray(arguments); - if(args.length === 0){ + if (args.length === 0) { this.date = new Date(); - }else if (isDate(y)) { + } else if (isDate(y)) { this.date = y; } else { var date = new Date(1970, 0, 1, 0, 0, 0); @@ -370,7 +368,7 @@ var hashToArray = function (hash) { * @name sql * @memberOf patio */ -var sql = { +sql = { /**@lends patio.sql*/ /** @@ -396,14 +394,14 @@ var sql = { * * @return {patio.sql.Identifier|patio.sql.QualifiedIdentifier|patio.sql.AliasedExpression} an identifier generated based on the name string. */ - identifier:function (s) { + identifier: function (s) { return sql.stringToIdentifier(s); }, /** * @see patio.sql.identifier */ - stringToIdentifier:function (name) { + stringToIdentifier: function (name) { !Dataset && (Dataset = require("./dataset")); return new Dataset().stringToIdentifier(name); }, @@ -431,7 +429,7 @@ var sql = { * @return {patio.sql.LiteralString|patio.sql.PlaceHolderLiteralString} an expression that can be used as an argument * for {@link patio.Dataset} query methods. */ - literal:function (s) { + literal: function (s) { var args = argsToArray(arguments); return args.length > 1 ? PlaceHolderLiteralString.fromArgs(args) : new LiteralString(s); }, @@ -444,7 +442,7 @@ var sql = { * sql["case"]({a:sql.b}, sql.c, sql.d); //=> (CASE t.d WHEN t.a THEN t.b ELSE t.c END) * */ - "case":function (hash, /*args**/opts) { + "case": function (hash, /*args**/opts) { var args = argsToArray(arguments, 1); return CaseExpression.fromArgs([hashToArray(hash)].concat(args)); }, @@ -464,11 +462,11 @@ var sql = { * patio.sql.sqlStringJoin([sql.a, 'b']) # SQL: a || 'b' * patio.sql.sqlStringJoin(['a', sql.b], ' '); //=> 'a' || ' ' || b */ - sqlStringJoin:function (arr, joiner) { + sqlStringJoin: function (arr, joiner) { joiner = joiner || null; var args; arr = arr.map(function (a) { - return isInstanceOf(a, Expression, LiteralString, Boolean) || isNull(a) ? a : sql.stringToIdentifier(a) + return isInstanceOf(a, Expression, LiteralString, Boolean) || isNull(a) ? a : sql.stringToIdentifier(a); }); if (joiner) { var newJoiner = []; @@ -486,16 +484,16 @@ var sql = { return StringExpression.fromArgs(["||"].concat(args)); }, - Year:Year, - TimeStamp:TimeStamp, - Time:Time, - DateTime:DateTime, - Float:Float, - Decimal:Decimal + Year: Year, + TimeStamp: TimeStamp, + Time: Time, + DateTime: DateTime, + Float: Float, + Decimal: Decimal }; -sql.__defineGetter__("patio", function () { +sql["__defineGetter__"]("patio", function () { !patio && (patio = require("./index")); return patio; }); @@ -505,64 +503,66 @@ exports.sql = methodMissing(sql, function (name) { }); var OPERTATOR_INVERSIONS = { - AND:"OR", - OR:"AND", - GT:"lte", - GTE:"lt", - LT:"gte", - LTE:"gt", - EQ:"neq", - NEQ:"eq", - LIKE:'NOT LIKE', - "NOT LIKE":"LIKE", - '!~*':'~*', - '~*':'!~*', - "~":'!~', - "IN":'NOTIN', - "NOTIN":"IN", - "IS":'IS NOT', - "ISNOT":"IS", - NOT:"NOOP", - NOOP:"NOT", - ILIKE:'NOT ILIKE', - NOTILIKE:"ILIKE" + AND: "OR", + OR: "AND", + GT: "lte", + GTE: "lt", + LT: "gte", + LTE: "gt", + EQ: "neq", + NEQ: "eq", + LIKE: 'NOT LIKE', + "NOT LIKE": "LIKE", + '!~*': '~*', + '~*': '!~*', + "~": '!~', + "IN": 'NOTIN', + "NOTIN": "IN", + "IS": 'IS NOT', + "ISNOT": "IS", + NOT: "NOOP", + NOOP: "NOT", + ILIKE: 'NOT ILIKE', + NOTILIKE: "ILIKE" }; // Standard mathematical operators used in +NumericMethods+ -var MATHEMATICAL_OPERATORS = {PLUS:"+", MINUS:"-", DIVIDE:"/", MULTIPLY:"*"}; +var MATHEMATICAL_OPERATORS = {PLUS: "+", MINUS: "-", DIVIDE: "/", MULTIPLY: "*"}; // Bitwise mathematical operators used in +NumericMethods+ -var BITWISE_OPERATORS = {bitWiseAnd:"&", bitWiseOr:"|", exclusiveOr:"^", leftShift:"<<", rightShift:">>"}; +var BITWISE_OPERATORS = {bitWiseAnd: "&", bitWiseOr: "|", exclusiveOr: "^", leftShift: "<<", rightShift: ">>"}; -var INEQUALITY_OPERATORS = {GT:">", GTE:">=", LT:"<", LTE:"<="}; +var INEQUALITY_OPERATORS = {GT: ">", GTE: ">=", LT: "<", LTE: "<="}; //Hash of ruby operator symbols to SQL operators, used in +BooleanMethods+ -var BOOLEAN_OPERATORS = {AND:"AND", OR:"OR"}; +var BOOLEAN_OPERATORS = {AND: "AND", OR: "OR"}; //Operators that use IN/NOT IN for inclusion/exclusion -var IN_OPERATORS = {IN:"IN", NOTIN:'NOT IN'}; +var IN_OPERATORS = {IN: "IN", NOTIN: 'NOT IN'}; //Operators that use IS, used for special casing to override literal true/false values -var IS_OPERATORS = {IS:"IS", ISNOT:'IS NOT'}; +var IS_OPERATORS = {IS: "IS", ISNOT: 'IS NOT'}; //Operator symbols that take exactly two arguments var TWO_ARITY_OPERATORS = merge({ - EQ:'=', - NEQ:'!=', LIKE:"LIKE", - "NOT LIKE":'NOT LIKE', - ILIKE:"ILIKE", - "NOT ILIKE":'NOT ILIKE', - "~":"~", - '!~':"!~", - '~*':"~*", - '!~*':"!~*"}, INEQUALITY_OPERATORS, BITWISE_OPERATORS, IS_OPERATORS, IN_OPERATORS); + EQ: '=', + NEQ: '!=', + LIKE: "LIKE", + "NOT LIKE": 'NOT LIKE', + ILIKE: "ILIKE", + "NOT ILIKE": 'NOT ILIKE', + "~": "~", + '!~': "!~", + '~*': "~*", + '!~*': "!~*" +}, INEQUALITY_OPERATORS, BITWISE_OPERATORS, IS_OPERATORS, IN_OPERATORS); //Operator symbols that take one or more arguments -var N_ARITY_OPERATORS = merge({"||":"||"}, BOOLEAN_OPERATORS, MATHEMATICAL_OPERATORS); +var N_ARITY_OPERATORS = merge({"||": "||"}, BOOLEAN_OPERATORS, MATHEMATICAL_OPERATORS); //Operator symbols that take only a single argument -var ONE_ARITY_OPERATORS = {"NOT":"NOT", "NOOP":"NOOP"}; +var ONE_ARITY_OPERATORS = {"NOT": "NOT", "NOOP": "NOOP"}; /** * @class Mixin to provide alias methods to an expression. @@ -571,7 +571,7 @@ var ONE_ARITY_OPERATORS = {"NOT":"NOT", "NOOP":"NOOP"}; * @memberOf patio.sql */ var AliasMethods = define(null, { - instance:{ + instance: { /**@lends patio.sql.AliasMethods.prototype*/ /** @@ -587,7 +587,7 @@ var AliasMethods = define(null, { * * @return {patio.sql.AliasedExpression} the aliased expression. */ - as:function (alias) { + as: function (alias) { return new AliasedExpression(this, alias); } @@ -602,7 +602,7 @@ var bitWiseMethod = function (op) { else { return new BooleanExpression(op, this, expression); } - } + }; }; /** @@ -620,7 +620,7 @@ var bitWiseMethod = function (op) { * @memberOf patio.sql */ var BitWiseMethods = define(null, { - instance:{ + instance: { /**@lends patio.sql.BitWiseMethods.prototype*/ /** @@ -629,7 +629,7 @@ var BitWiseMethods = define(null, { * @example * sql.a.sqlNumber.bitWiseAnd("b"); //=> "a" & "b" */ - bitWiseAnd:bitWiseMethod("bitWiseAnd"), + bitWiseAnd: bitWiseMethod("bitWiseAnd"), /** * Bitwise or @@ -637,7 +637,7 @@ var BitWiseMethods = define(null, { * @example * sql.a.sqlNumber.bitWiseOr("b") //=> "a" | "b" */ - bitWiseOr:bitWiseMethod("bitWiseOr"), + bitWiseOr: bitWiseMethod("bitWiseOr"), /** * Exclusive Or @@ -646,7 +646,7 @@ var BitWiseMethods = define(null, { * * sql.a.sqlNumber.exclusiveOr("b") //=> "a" ^ "b" */ - exclusiveOr:bitWiseMethod("exclusiveOr"), + exclusiveOr: bitWiseMethod("exclusiveOr"), /** * Bitwise shift left @@ -655,7 +655,7 @@ var BitWiseMethods = define(null, { * * sql.a.sqlNumber.leftShift("b") // "a" << "b" */ - leftShift:bitWiseMethod("leftShift"), + leftShift: bitWiseMethod("leftShift"), /** * Bitwise shift right @@ -664,7 +664,7 @@ var BitWiseMethods = define(null, { * * sql.a.sqlNumber.rightShift("b") //=> "a" >> "b" */ - rightShift:bitWiseMethod("rightShift") + rightShift: bitWiseMethod("rightShift") } }).as(sql, "BitWiseMethods"); @@ -676,7 +676,7 @@ var booleanMethod = function (op) { else { return new BooleanExpression(op, this, expression); } - } + }; }; /** @@ -693,7 +693,7 @@ var booleanMethod = function (op) { * @memberOf patio.sql */ var BooleanMethods = define(null, { - instance:{ + instance: { /**@lends patio.sql.BooleanMethods.prototype*/ /** @@ -707,7 +707,7 @@ var BooleanMethods = define(null, { * * @return {patio.sql.BooleanExpression} a ANDed boolean expression. */ - and:booleanMethod("and"), + and: booleanMethod("and"), /** * @function @@ -719,7 +719,7 @@ var BooleanMethods = define(null, { * * @return {patio.sql.BooleanExpression} a ORed boolean expression */ - or:booleanMethod("or"), + or: booleanMethod("or"), /** * Logical NOT @@ -730,7 +730,7 @@ var BooleanMethods = define(null, { * * @return {patio.sql.BooleanExpression} a inverted boolean expression. */ - not:function () { + not: function () { return BooleanExpression.invert(this); } @@ -744,7 +744,7 @@ var BooleanMethods = define(null, { * @memberOf patio.sql */ var CastMethods = define(null, { - instance:{ + instance: { /**@lends patio.sql.CastMethods.prototype*/ /** * Cast the reciever to the given SQL type. @@ -756,7 +756,7 @@ var CastMethods = define(null, { * * @return {patio.sql.Cast} the casted expression */ - cast:function (type) { + cast: function (type) { return new Cast(this, type); }, @@ -772,7 +772,7 @@ var CastMethods = define(null, { * * @return {patio.sql.NumericExpression} a casted numberic expression */ - castNumeric:function (type) { + castNumeric: function (type) { return this.cast(type || "integer").sqlNumber; }, @@ -788,7 +788,7 @@ var CastMethods = define(null, { * * @return {patio.sql.StringExpression} the casted string expression */ - castString:function (type) { + castString: function (type) { return this.cast(type || String).sqlString; } } @@ -815,14 +815,14 @@ var CastMethods = define(null, { * */ var ComplexExpressionMethods = define(null, { - instance:{ + instance: { /**@ignore*/ - getters:{ + getters: { /** * @ignore */ - sqlBoolean:function () { + sqlBoolean: function () { return new BooleanExpression("noop", this); }, @@ -830,7 +830,7 @@ var ComplexExpressionMethods = define(null, { /** * @ignore */ - sqlFunction:function () { + sqlFunction: function () { return new SQLFunction(this); }, @@ -838,14 +838,14 @@ var ComplexExpressionMethods = define(null, { /** * @ignore */ - sqlNumber:function () { + sqlNumber: function () { return new NumericExpression("noop", this); }, /** * @ignore */ - sqlString:function () { + sqlString: function () { return new StringExpression("noop", this); } } @@ -854,16 +854,16 @@ var ComplexExpressionMethods = define(null, { var inequalityMethod = function (op) { return function (expression) { - if (isInstanceOf(expression, BooleanExpression) - || isBoolean(expression) - || isNull(expression) - || (isHash(expression)) - || isArray(expression)) { + if (isInstanceOf(expression, BooleanExpression) || + isBoolean(expression) || + isNull(expression) || + (isHash(expression)) || + isArray(expression)) { throw new ExpressionError("Cannot apply " + op + " to a boolean expression"); } else { return new BooleanExpression(op, this, expression); } - } + }; }; /** @@ -881,7 +881,7 @@ var inequalityMethod = function (op) { * @memberOf patio.sql */ var InequalityMethods = define(null, { - instance:{ + instance: { /**@lends patio.sql.InequalityMethods.prototype*/ /** @@ -892,7 +892,7 @@ var InequalityMethods = define(null, { * * @return {patio.sql.BooleanExpression} */ - gt:inequalityMethod("gt"), + gt: inequalityMethod("gt"), /** * @function Creates a gte {@link patio.sql.BooleanExpression} compared to this expression. * @@ -902,7 +902,7 @@ var InequalityMethods = define(null, { * * @return {patio.sql.BooleanExpression} */ - gte:inequalityMethod("gte"), + gte: inequalityMethod("gte"), /** * @function Creates a lt {@link patio.sql.BooleanExpression} compared to this expression. * @@ -912,7 +912,7 @@ var InequalityMethods = define(null, { * * @return {patio.sql.BooleanExpression} */ - lt:inequalityMethod("lt"), + lt: inequalityMethod("lt"), /** * @function Creates a lte {@link patio.sql.BooleanExpression} compared to this expression. * @@ -922,7 +922,7 @@ var InequalityMethods = define(null, { * * @return {patio.sql.BooleanExpression} */ - lte:inequalityMethod("lte"), + lte: inequalityMethod("lte"), /** * @function Creates a eq {@link patio.sql.BooleanExpression} compared to this expression. * @@ -932,9 +932,9 @@ var InequalityMethods = define(null, { * * @return {patio.sql.BooleanExpression} */ - eq:inequalityMethod("eq"), + eq: inequalityMethod("eq"), - neq:inequalityMethod("neq"), + neq: inequalityMethod("neq"), /** * @private @@ -950,8 +950,8 @@ var InequalityMethods = define(null, { * * @return {patio.sql.BooleanExpression} a boolean expression containing the between expression. */ - between:function (items) { - return new BooleanExpression("AND", new BooleanExpression("gte", this, items[0]), new BooleanExpression("lte", this, items[1])) + between: function (items) { + return new BooleanExpression("AND", new BooleanExpression("gte", this, items[0]), new BooleanExpression("lte", this, items[1])); } } }).as(sql, "InequalityMethods"); @@ -965,15 +965,15 @@ var InequalityMethods = define(null, { * @memberOf patio.sql */ var NoBooleanInputMethods = define(null, { - instance:{ - constructor:function (op) { + instance: { + constructor: function (op) { var args = argsToArray(arguments, 1); args.forEach(function (expression) { - if ((isInstanceOf(expression, BooleanExpression)) - || isBoolean(expression) - || isNull(expression) - || (isObject(expression) && !isInstanceOf(expression, Expression, Dataset, LiteralString)) - || isArray(expression)) { + if ((isInstanceOf(expression, BooleanExpression)) || + isBoolean(expression) || + isNull(expression) || + (isObject(expression) && !isInstanceOf(expression, Expression, Dataset, LiteralString)) || + isArray(expression)) { throw new ExpressionError("Cannot apply " + op + " to a boolean expression"); } }); @@ -989,7 +989,7 @@ var numericMethod = function (op) { } else { return new NumericExpression(op, this, expression); } - } + }; }; @@ -1007,7 +1007,7 @@ var numericMethod = function (op) { * @memberOf patio.sql */ var NumericMethods = define(null, { - instance:{ + instance: { /**@lends patio.sql.NumericMethods.prototype*/ @@ -1020,7 +1020,7 @@ var NumericMethods = define(null, { * * @return {patio.sql.NumericExpression} */ - plus:numericMethod("plus"), + plus: numericMethod("plus"), /** * @function Subtracts the provided expression from this expression and returns a {@link patio.sql.NumericExpression}. @@ -1031,7 +1031,7 @@ var NumericMethods = define(null, { * * @return {patio.sql.NumericExpression} */ - minus:numericMethod("minus"), + minus: numericMethod("minus"), /** * @function Divides this expression by the provided expression and returns a {@link patio.sql.NumericExpression}. @@ -1042,7 +1042,7 @@ var NumericMethods = define(null, { * * @return {patio.sql.NumericExpression} */ - divide:numericMethod("divide"), + divide: numericMethod("divide"), /** * @function Divides this expression by the provided expression and returns a {@link patio.sql.NumericExpression}. @@ -1053,7 +1053,7 @@ var NumericMethods = define(null, { * * @return {patio.sql.NumericExpression} */ - multiply:numericMethod("multiply") + multiply: numericMethod("multiply") } }).as(sql, "NumericMethods"); @@ -1072,7 +1072,7 @@ var NumericMethods = define(null, { * @memberOf patio.sql */ var OrderedMethods = define(null, { - instance:{ + instance: { /**@lends patio.sql.OrderedMethods.prototype*/ /** @@ -1087,7 +1087,7 @@ var OrderedMethods = define(null, { * before other values), or "last" to use NULLS LAST (so NULL values are ordered after other values). * @return {patio.sql.OrderedExpression} */ - asc:function (options) { + asc: function (options) { return new OrderedExpression(this, false, options); }, @@ -1103,7 +1103,7 @@ var OrderedMethods = define(null, { * before other values), or "last" to use NULLS LAST (so NULL values are ordered after other values). * @return {patio.sql.OrderedExpression} */ - desc:function (options) { + desc: function (options) { return new OrderedExpression(this, true, options); } } @@ -1123,7 +1123,7 @@ var OrderedMethods = define(null, { * @memberOf patio.sql */ var QualifyingMethods = define(null, { - instance:{ + instance: { /**@lends patio.sql.QualifyingMethods.prototype*/ /** @@ -1138,7 +1138,7 @@ var QualifyingMethods = define(null, { * * @return {patio.sql.QualifiedIdentifier} */ - qualify:function (qualifier) { + qualify: function (qualifier) { return new QualifiedIdentifier(qualifier, this); }, @@ -1152,7 +1152,7 @@ var QualifyingMethods = define(null, { * * @return {patio.sql.ColumnAll} */ - all:function () { + all: function () { return new ColumnAll(this); } @@ -1174,7 +1174,7 @@ var QualifyingMethods = define(null, { * @memberOf patio.sql */ var StringMethods = define(null, { - instance:{ + instance: { /**@lends patio.sql.StringMethods.prototype*/ /** @@ -1186,10 +1186,10 @@ var StringMethods = define(null, { * * @return {patio.sql.BooleanExpression} */ - ilike:function (expression) { + ilike: function (expression) { expression = argsToArray(arguments); return StringExpression.like.apply(StringExpression, [this].concat(expression).concat([ - {caseInsensitive:true} + {caseInsensitive: true} ])); }, @@ -1203,7 +1203,7 @@ var StringMethods = define(null, { * * @param expression */ - like:function (expression) { + like: function (expression) { expression = argsToArray(arguments); return StringExpression.like.apply(StringExpression, [this].concat(expression)); } @@ -1221,7 +1221,7 @@ var StringMethods = define(null, { * @memberOf patio.sql */ var StringConcatenationMethods = define(null, { - instance:{ + instance: { /**@lends patio.sql.StringConcatenationMethods.prototype*/ /** @@ -1234,7 +1234,7 @@ var StringConcatenationMethods = define(null, { * * @param expression expression to concatenate this expression with. */ - concat:function (expression) { + concat: function (expression) { return new StringExpression("||", this, expression); } } @@ -1252,7 +1252,7 @@ var StringConcatenationMethods = define(null, { * @memberOf patio.sql */ var SubscriptMethods = define(null, { - instance:{ + instance: { /** * Return a {@link patio.sql.Subscript} with the given arguments, representing an @@ -1265,7 +1265,7 @@ var SubscriptMethods = define(null, { * * @param subscript */ - sqlSubscript:function (subscript) { + sqlSubscript: function (subscript) { var args = argsToArray(arguments); return new SubScript(this, flatten(args)); } @@ -1279,9 +1279,9 @@ var SubscriptMethods = define(null, { * @name Expression * @memberOf patio.sql */ -var Expression = define(null, { +Expression = define(null, { - instance:{ + instance: { /**@lends patio.sql.Expression.prototype*/ /** @@ -1290,13 +1290,13 @@ var Expression = define(null, { * @param {patio.Dataset} ds the dataset that will be used to SQL-ify this expression. * @return {String} a string literal version of this expression. */ - sqlLiteral:function (ds) { + sqlLiteral: function (ds) { return this.toString(ds); } }, - static:{ + static: { /**@lends patio.sql.Expression*/ /** @@ -1310,10 +1310,10 @@ var Expression = define(null, { * * @return {patio.sql.Expression} an expression. */ - fromArgs:function (args) { - var ret; + fromArgs: function (args) { + var ret, Self = this; try { - ret = new this(); + ret = new Self(); } catch (ignore) { } this.apply(ret, args); @@ -1333,7 +1333,7 @@ var Expression = define(null, { * @param {*} obj object to test if it is a condition specifier * @return {Boolean} true if the object is a Hash or is an array of two element arrays. */ - isConditionSpecifier:function (obj) { + isConditionSpecifier: function (obj) { return isHash(obj) || (isArray(obj) && obj.length && obj.every(function (i) { return isArray(i) && i.length === 2; })); @@ -1362,8 +1362,8 @@ var Expression = define(null, { var GenericExpression = define([Expression, AliasMethods, BooleanMethods, CastMethods, ComplexExpressionMethods, InequalityMethods, NumericMethods, OrderedMethods, StringMethods, SubscriptMethods]).as(sql, "GenericExpression"); -var AliasedExpression = define(Expression, { - instance:{ +AliasedExpression = define(Expression, { + instance: { /**@lends patio.sql.AliasedExpression.prototype*/ /** @@ -1379,7 +1379,7 @@ var AliasedExpression = define(Expression, { * @property alias the alias of the expression * */ - constructor:function (expression, alias) { + constructor: function (expression, alias) { this.expression = expression; this.alias = alias; }, @@ -1391,7 +1391,7 @@ var AliasedExpression = define(Expression, { * * @return String the SQL alias fragment. */ - toString:function (ds) { + toString: function (ds) { !Dataset && (Dataset = require("./dataset")); ds = ds || new Dataset(); return ds.aliasedExpressionSql(this); @@ -1401,8 +1401,8 @@ var AliasedExpression = define(Expression, { ).as(sql, "AliasedExpression"); -var CaseExpression = define(GenericExpression, { - instance:{ +CaseExpression = define(GenericExpression, { + instance: { /**@lends patio.sql.CaseExpression.prototype*/ /** @@ -1423,7 +1423,7 @@ var CaseExpression = define(GenericExpression, { * @property expression the expression of the {@link patio.sql.CaseExpression}. * @property {Boolean} noExpression true if this {@link patio.sql.CaseExpression}'s expression is undefined. */ - constructor:function (conditions, def, expression) { + constructor: function (conditions, def, expression) { if (Expression.isConditionSpecifier(conditions)) { this.conditions = toArray(conditions); this.def = def; @@ -1440,16 +1440,16 @@ var CaseExpression = define(GenericExpression, { * * @return String the SQL case expression fragment. */ - toString:function (ds) { + toString: function (ds) { !Dataset && (Dataset = require("./dataset")); ds = ds || new Dataset(); return ds.caseExpressionSql(this); }, /**@ignore*/ - getters:{ + getters: { /**@ignore*/ - hasExpression:function () { + hasExpression: function () { return !this.noExpression; } } @@ -1457,8 +1457,8 @@ var CaseExpression = define(GenericExpression, { }).as(sql, "CaseExpression"); -var Cast = define(GenericExpression, { - instance:{ +Cast = define(GenericExpression, { + instance: { /**@lends patio.sql.Cast*/ /** @@ -1472,7 +1472,7 @@ var Cast = define(GenericExpression, { * @property expr the expression to CAST. * @property type the type to CAST the expression to. */ - constructor:function (expr, type) { + constructor: function (expr, type) { this.expr = expr; this.type = type; }, @@ -1485,7 +1485,7 @@ var Cast = define(GenericExpression, { * * @return String the SQL cast expression fragment. */ - toString:function (ds) { + toString: function (ds) { !Dataset && (Dataset = require("./dataset")); ds = ds || new Dataset(); return ds.castSql(this.expr, this.type); @@ -1494,8 +1494,8 @@ var Cast = define(GenericExpression, { }).as(sql, "Cast"); -var ColumnAll = define(Expression, { - instance:{ +ColumnAll = define(Expression, { + instance: { /**@lends patio.sql.ColumnAll.prototype*/ /** @@ -1508,7 +1508,7 @@ var ColumnAll = define(Expression, { * * @property table the table this all column expression represents. */ - constructor:function (table) { + constructor: function (table) { this.table = table; }, @@ -1520,7 +1520,7 @@ var ColumnAll = define(Expression, { * * @return String the SQL columnAll expression fragment. */ - toString:function (ds) { + toString: function (ds) { !Dataset && (Dataset = require("./dataset")); ds = ds || new Dataset(); return ds.columnAllSql(this); @@ -1529,7 +1529,7 @@ var ColumnAll = define(Expression, { }).as(sql, "ColumnAll"); var ComplexExpression = define([Expression, AliasMethods, CastMethods, OrderedMethods, SubscriptMethods], { - instance:{ + instance: { /**@lends patio.sql.ComplexExpression.prototype*/ /** @@ -1558,9 +1558,9 @@ var ComplexExpression = define([Expression, AliasMethods, CastMethods, OrderedMe * other than the second arg for an IN/NOT IN operator. *

    */ - constructor:function (op) { + constructor: function (op) { if (op) { - var args = argsToArray(arguments,1 ); + var args = argsToArray(arguments, 1); //make a copy of the args var origArgs = args.slice(0); args.forEach(function (a, i) { @@ -1572,26 +1572,26 @@ var ComplexExpression = define([Expression, AliasMethods, CastMethods, OrderedMe if (N_ARITY_OPERATORS.hasOwnProperty(op)) { if (args.length < 1) { - throw new ExpressionError("The " + op + " operator requires at least 1 argument") + throw new ExpressionError("The " + op + " operator requires at least 1 argument"); } var oldArgs = args.slice(0); args = []; oldArgs.forEach(function (a) { - a instanceof ComplexExpression && a.op == op ? args = args.concat(a.args) : args.push(a); + a instanceof ComplexExpression && a.op === op ? args = args.concat(a.args) : args.push(a); }); } else if (TWO_ARITY_OPERATORS.hasOwnProperty(op)) { - if (args.length != 2) { + if (args.length !== 2) { throw new ExpressionError("The " + op + " operator requires precisely 2 arguments"); } //With IN/NOT IN, even if the second argument is an array of two element arrays, //don't convert it into a boolean expression, since it's definitely being used //as a value list. if (IN_OPERATORS[op]) { - args[1] = origArgs[1] + args[1] = origArgs[1]; } } else if (ONE_ARITY_OPERATORS.hasOwnProperty(op)) { - if (args.length != 1) { + if (args.length !== 1) { throw new ExpressionError("The " + op + " operator requires only one argument"); } } else { @@ -1610,14 +1610,14 @@ var ComplexExpression = define([Expression, AliasMethods, CastMethods, OrderedMe * * @return String the SQL version of the {@link patio.sql.ComplexExpression}. */ - toString:function (ds) { + toString: function (ds) { !Dataset && (Dataset = require("./dataset")); ds = ds || new Dataset(); return ds.complexExpressionSql(this.op, this.args); } }, - static:{ + static: { /**@lends patio.sql.ComplexExpression*/ /** @@ -1647,7 +1647,7 @@ var ComplexExpression = define([Expression, AliasMethods, CastMethods, OrderedMe * NOTILIKE:"ILIKE" * } */ - OPERATOR_INVERSIONS:OPERTATOR_INVERSIONS, + OPERATOR_INVERSIONS: OPERTATOR_INVERSIONS, /** * Default mathematical operators. @@ -1655,7 +1655,7 @@ var ComplexExpression = define([Expression, AliasMethods, CastMethods, OrderedMe * @type Object * @default {PLUS:"+", MINUS:"-", DIVIDE:"/", MULTIPLY:"*"} */ - MATHEMATICAL_OPERATORS:MATHEMATICAL_OPERATORS, + MATHEMATICAL_OPERATORS: MATHEMATICAL_OPERATORS, /** * Default bitwise operators. @@ -1663,14 +1663,14 @@ var ComplexExpression = define([Expression, AliasMethods, CastMethods, OrderedMe * @type Object * @default {bitWiseAnd:"&", bitWiseOr:"|", exclusiveOr:"^", leftShift:"<<", rightShift:">>"} */ - BITWISE_OPERATORS:BITWISE_OPERATORS, + BITWISE_OPERATORS: BITWISE_OPERATORS, /** * Default inequality operators. * * @type Object * @default {GT:">",GTE:">=",LT:"<",LTE:"<="} */ - INEQUALITY_OPERATORS:INEQUALITY_OPERATORS, + INEQUALITY_OPERATORS: INEQUALITY_OPERATORS, /** * Default boolean operators. @@ -1678,7 +1678,7 @@ var ComplexExpression = define([Expression, AliasMethods, CastMethods, OrderedMe * @type Object * @default {AND:"AND",OR:"OR"} */ - BOOLEAN_OPERATORS:BOOLEAN_OPERATORS, + BOOLEAN_OPERATORS: BOOLEAN_OPERATORS, /** * Default IN operators. @@ -1686,14 +1686,14 @@ var ComplexExpression = define([Expression, AliasMethods, CastMethods, OrderedMe * @type Object * @default {IN:"IN",NOTIN:'NOT IN'} */ - IN_OPERATORS:IN_OPERATORS, + IN_OPERATORS: IN_OPERATORS, /** * Default IS operators. * * @type Object * @default {IS:"IS", ISNOT:'IS NOT'} */ - IS_OPERATORS:IS_OPERATORS, + IS_OPERATORS: IS_OPERATORS, /** * Default two arity operators. * @@ -1723,7 +1723,7 @@ var ComplexExpression = define([Expression, AliasMethods, CastMethods, OrderedMe * NOTIN:'NOT IN' * } */ - TWO_ARITY_OPERATORS:TWO_ARITY_OPERATORS, + TWO_ARITY_OPERATORS: TWO_ARITY_OPERATORS, /** * Default N(multi) arity operators. @@ -1738,7 +1738,7 @@ var ComplexExpression = define([Expression, AliasMethods, CastMethods, OrderedMe * DIVIDE:"/", MULTIPLY:"*" * } */ - N_ARITY_OPERATORS:N_ARITY_OPERATORS, + N_ARITY_OPERATORS: N_ARITY_OPERATORS, /** * Default ONE operators. @@ -1749,7 +1749,7 @@ var ComplexExpression = define([Expression, AliasMethods, CastMethods, OrderedMe * "NOOP":"NOOP" * } */ - ONE_ARITY_OPERATORS:ONE_ARITY_OPERATORS + ONE_ARITY_OPERATORS: ONE_ARITY_OPERATORS } }).as(sql, "ComplexExpression"); @@ -1763,8 +1763,8 @@ var ComplexExpression = define([Expression, AliasMethods, CastMethods, OrderedMe * @name BooleanExpression * @memberOf patio.sql */ -var BooleanExpression = define([ComplexExpression, BooleanMethods], { - static:{ +BooleanExpression = define([ComplexExpression, BooleanMethods], { + static: { /**@lends patio.sql.BooleanExpression*/ /** @@ -1781,10 +1781,10 @@ var BooleanExpression = define([ComplexExpression, BooleanMethods], { * * @return {patio.sql.BooleanExpression} the inverted expression. */ - invert:function (expression) { + invert: function (expression) { if (isInstanceOf(expression, BooleanExpression)) { var op = expression.op, newArgs; - if (op == "AND" || op == "OR") { + if (op === "AND" || op === "OR") { newArgs = [OPERTATOR_INVERSIONS[op]].concat(expression.args.map(function (arg) { return BooleanExpression.invert(arg); })); @@ -1829,20 +1829,20 @@ var BooleanExpression = define([ComplexExpression, BooleanMethods], { * * @return {patio.sql.BooleanExpression} expression composed of sub expressions built from the hash. */ - fromValuePairs:function (a, op, negate) { + fromValuePairs: function (a, op, negate) { !Dataset && (Dataset = require("./dataset")); op = op || "AND", negate = negate || false; var pairArr = []; var isArr = isArray(a) && Expression.isConditionSpecifier(a); if (isHash(a)) { - pairArr.push(this.__filterObject(a)); + pairArr.push(this.__filterObject(a, null, op)); } else { for (var k in a) { var v = isArr ? a[k][1] : a[k], ret; k = isArr ? a[k][0] : k; if (isArray(v) || isInstanceOf(v, Dataset)) { k = isArray(k) ? k.map(function (i) { - return isString(i) ? sql.stringToIdentifier(i) : i + return isString(i) ? sql.stringToIdentifier(i) : i; }) : isString(k) ? sql.stringToIdentifier(k) : k; ret = new BooleanExpression("IN", k, v); } else if (isInstanceOf(v, NegativeBooleanConstant)) { @@ -1852,7 +1852,7 @@ var BooleanExpression = define([ComplexExpression, BooleanMethods], { } else if (isNull(v) || isBoolean(v)) { ret = new BooleanExpression("IS", k, v); } else if (isHash(v)) { - ret = BooleanExpression.__filterObject(v, k); + ret = BooleanExpression.__filterObject(v, k, op); } else if (isRegExp(v)) { ret = StringExpression.like(sql.stringToIdentifier(k), v); } else { @@ -1887,13 +1887,13 @@ var BooleanExpression = define([ComplexExpression, BooleanMethods], { * * @return {patio.sql.Expression} an expression to use in the filter */ - __filterObject:function (expr, key) { + __filterObject: function (expr, key, op) { var pairs = [], opts, newKey; var twoArityOperators = this.TWO_ARITY_OPERATORS; for (var k in expr) { var v = expr[k]; if (isHash(v)) { //its a hash too filter it too! - pairs.push(this.__filterObject(v, k)); + pairs.push(this.__filterObject(v, k, op)); } else if (key && (twoArityOperators[k.toUpperCase()] || k.match(/between/i))) { //its a two arrity operator (e.g. '=', '>') newKey = isString(key) ? key.split(",") : [key]; @@ -1902,7 +1902,7 @@ var BooleanExpression = define([ComplexExpression, BooleanMethods], { //(e.g. {"col1,col2" : 1}) => WHERE (col1 = 1 AND col2 = 1) pairs = pairs.concat(newKey.map(function (k) { //filter each column with the expression - return this.__filterObject(expr, k); + return this.__filterObject(expr, k, op); }, this)); } else { newKey = [sql.stringToIdentifier(newKey[0])]; @@ -1912,7 +1912,7 @@ var BooleanExpression = define([ComplexExpression, BooleanMethods], { pairs.push(StringExpression.like.apply(StringExpression, (newKey.concat(isArray(v) ? v : [v])))); } else if (k.match(/^iLike$/)) { //its a like clause {col : {iLike : "hello"}} - pairs.push(StringExpression.like.apply(StringExpression, (newKey.concat(isArray(v) ? v : [v]).concat({caseInsensitive:true})))); + pairs.push(StringExpression.like.apply(StringExpression, (newKey.concat(isArray(v) ? v : [v]).concat({caseInsensitive: true})))); } else if (k.match(/between/i)) { //its a like clause {col : {between : [1,10]}} var between = sql.stringToIdentifier(newKey[0]).between(v); @@ -1940,14 +1940,14 @@ var BooleanExpression = define([ComplexExpression, BooleanMethods], { } //if the total of pairs is one then we just return the first element //otherwise we join them all with an AND - return pairs.length == 1 ? pairs[0] : BooleanExpression.fromArgs(["AND"].concat(pairs)); + return pairs.length == 1 ? pairs[0] : BooleanExpression.fromArgs([op || "AND"].concat(pairs)); } } }).as(sql, "BooleanExpression"); var Constant = define(GenericExpression, { - instance:{ + instance: { /**@lends patio.sql.Constant.prototype*/ /** * Represents constants or psuedo-constants (e.g.'CURRENT_DATE) in SQL. @@ -1956,7 +1956,7 @@ var Constant = define(GenericExpression, { * @augments patio.sql.GenericExpression * @property {String} constant READ ONLY the contant. */ - constructor:function (constant) { + constructor: function (constant) { this.__constant = constant; }, @@ -1968,14 +1968,14 @@ var Constant = define(GenericExpression, { * * @return String the SQL version of the {@link patio.sql.Constant}. */ - toString:function (ds) { + toString: function (ds) { !Dataset && (Dataset = require("./dataset")); ds = ds || new Dataset(); return ds.constantSql(this.__constant); }, - getters:{ - constant:function () { + getters: { + constant: function () { return this.__constant; } } @@ -1989,7 +1989,7 @@ var Constant = define(GenericExpression, { * @memberOf patio.sql */ var BooleanConstant = define(Constant, { - instance:{ + instance: { /**@lends patio.sql.BooleanConstant.prototype*/ /** @@ -2000,7 +2000,7 @@ var BooleanConstant = define(Constant, { * * @return String the SQL version of the {@link patio.sql.BooleanConstant}. */ - toString:function (ds) { + toString: function (ds) { !Dataset && (Dataset = require("./dataset")); ds = ds || new Dataset(); return ds.booleanConstantSql(this.__constant); @@ -2017,7 +2017,7 @@ var BooleanConstant = define(Constant, { * @memberOf patio.sql */ var NegativeBooleanConstant = define(BooleanConstant, { - instance:{ + instance: { /**@lends patio.sql.NegativeBooleanConstant.prototype*/ /** @@ -2028,7 +2028,7 @@ var NegativeBooleanConstant = define(BooleanConstant, { * * @return String the SQL version of the {@link patio.sql.NegativeBooleanConstant}. */ - toString:function (ds) { + toString: function (ds) { !Dataset && (Dataset = require("./dataset")); ds = ds || new Dataset(); return ds.negativeBooleanConstantSql(this.__constant); @@ -2049,61 +2049,61 @@ sql.Constants = { * Constant for CURRENT DATE * @type patio.sql.Constant */ - CURRENT_DATE:new Constant("CURRENT_DATE"), + CURRENT_DATE: new Constant("CURRENT_DATE"), /** * Constant for CURRENT TIME * @type patio.sql.Constant */ - CURRENT_TIME:new Constant("CURRENT_TIME"), + CURRENT_TIME: new Constant("CURRENT_TIME"), /** * Constant for CURRENT TIMESTAMP * @type patio.sql.Constant */ - CURRENT_TIMESTAMP:new Constant("CURRENT_TIMESTAMP"), + CURRENT_TIMESTAMP: new Constant("CURRENT_TIMESTAMP"), /** * Constant for TRUE * @type patio.sql.BooleanConstant */ - SQLTRUE:new BooleanConstant(1), + SQLTRUE: new BooleanConstant(1), /** * Constant for TRUE * @type patio.sql.BooleanConstant */ - TRUE:new BooleanConstant(1), + TRUE: new BooleanConstant(1), /** * Constant for FALSE. * @type patio.sql.BooleanConstant */ - SQLFALSE:new BooleanConstant(0), + SQLFALSE: new BooleanConstant(0), /** * Constant for FALSE * @type patio.sql.BooleanConstant */ - FALSE:new BooleanConstant(0), + FALSE: new BooleanConstant(0), /** * Constant for NULL * @type patio.sql.BooleanConstant */ - NULL:new BooleanConstant(null), + NULL: new BooleanConstant(null), /** * Constant for NOT NULL * @type patio.sql.NegativeBooleanConstant */ - NOTNULL:new NegativeBooleanConstant(null) + NOTNULL: new NegativeBooleanConstant(null) }; var Constants = sql.Constants var Identifier = define([GenericExpression, QualifyingMethods], { - instance:{ + instance: { /**@lends patio.sql.Identifier.prototype*/ /** @@ -2119,7 +2119,7 @@ var Identifier = define([GenericExpression, QualifyingMethods], { * * @property {String} value READ ONLY the column or table this identifier represents. */ - constructor:function (value) { + constructor: function (value) { this.__value = value; }, @@ -2131,15 +2131,15 @@ var Identifier = define([GenericExpression, QualifyingMethods], { * * @return String the SQL version of the {@link patio.sql.Identifier}. */ - toString:function (ds) { + toString: function (ds) { !Dataset && (Dataset = require("./dataset")); ds = ds || new Dataset(); return ds.quoteIdentifier(this); }, /**@ignore*/ - getters:{ - value:function () { + getters: { + value: function () { return this.__value; } } @@ -2147,7 +2147,7 @@ var Identifier = define([GenericExpression, QualifyingMethods], { }).as(sql, "Identifier"); var JoinClause = define(Expression, { - instance:{ + instance: { /**@lends patio.sql.JoinClause.prototype*/ /** @@ -2164,7 +2164,7 @@ var JoinClause = define(Expression, { * @property table READ ONLY the table to join with * @property joinType READ ONLY the alias to use for this join clause * */ - constructor:function (joinType, table, tableAlias) { + constructor: function (joinType, table, tableAlias) { this.__joinType = joinType; this.__table = table; this.__tableAlias = tableAlias || null; @@ -2178,23 +2178,23 @@ var JoinClause = define(Expression, { * * @return String the SQL version of the {@link patio.sql.JoinClause}. */ - toString:function (ds) { + toString: function (ds) { !Dataset && (Dataset = require("./dataset")); ds = ds || new Dataset(); return ds.joinClauseSql(this); }, /**@ignore*/ - getters:{ - joinType:function () { + getters: { + joinType: function () { return this.__joinType; }, - table:function () { + table: function () { return this.__table; }, - tableAlias:function () { + tableAlias: function () { return this.__tableAlias; } } @@ -2203,7 +2203,7 @@ var JoinClause = define(Expression, { var JoinOnClause = define(JoinClause, { - instance:{ + instance: { /**@lends patio.sql.JoinOnClause.prototype*/ /** * Represents an SQL JOIN clause with ON conditions. Created by {@link patio.Dataset} join methods. @@ -2214,7 +2214,7 @@ var JoinOnClause = define(JoinClause, { * @param on the expression to filter with. See {@link patio.Dataset#filter} * @property on READ ONLY the filter to use with joining the datasets. */ - constructor:function (on, joinType, table, tableAlias) { + constructor: function (on, joinType, table, tableAlias) { this.__on = on; this._super(arguments, [joinType, table, tableAlias]); }, @@ -2227,15 +2227,15 @@ var JoinOnClause = define(JoinClause, { * * @return String the SQL version of the {@link patio.sql.JoinOnClause}. */ - toString:function (ds) { + toString: function (ds) { !Dataset && (Dataset = require("./dataset")); ds = ds || new Dataset(); return ds.joinOnClauseSql(this); }, /**@ignore*/ - getters:{ - on:function () { + getters: { + on: function () { return this.__on; } } @@ -2244,7 +2244,7 @@ var JoinOnClause = define(JoinClause, { var JoinUsingClause = define(JoinClause, { - instance:{ + instance: { /**@lends patio.sql.JoinUsingClause.prototype*/ /** @@ -2258,7 +2258,7 @@ var JoinUsingClause = define(JoinClause, { * @param using the column/s to use when joining. * @property using READ ONLY the column/s to use when joining. */ - constructor:function (using, joinType, table, tableAlias) { + constructor: function (using, joinType, table, tableAlias) { this.__using = using.map(function (u) { return isString(u) ? new Identifier(u) : u; }); @@ -2273,15 +2273,15 @@ var JoinUsingClause = define(JoinClause, { * * @return String the SQL version of the {@link patio.sql.JoinUsingClause}. */ - toString:function (ds) { + toString: function (ds) { !Dataset && (Dataset = require("./dataset")); ds = ds || new Dataset(); return ds.joinUsingClauseSql(this); }, /**@ignore*/ - getters:{ - using:function () { + getters: { + using: function () { return this.__using; } } @@ -2290,7 +2290,7 @@ var JoinUsingClause = define(JoinClause, { var PlaceHolderLiteralString = define(GenericExpression, { - instance:{ + instance: { /**@lends patio.sql.PlaceHolderLiteralString.prototype*/ /** @@ -2312,7 +2312,7 @@ var PlaceHolderLiteralString = define(GenericExpression, { * replaced in the string. * @property {String} parens READ ONLY set to true to wrap the string in parens. */ - constructor:function (str, args, parens) { + constructor: function (str, args, parens) { parens = parens || false; var v; this.__str = str; @@ -2328,22 +2328,22 @@ var PlaceHolderLiteralString = define(GenericExpression, { * * @return String the SQL version of the {@link patio.sql.PlaceHolderLiteralString}. */ - toString:function (ds) { + toString: function (ds) { !Dataset && (Dataset = require("./dataset")); ds = ds || new Dataset(); return ds.placeholderLiteralStringSql(this); }, /**@ignore*/ - getters:{ - str:function () { + getters: { + str: function () { return this.__str; }, - args:function () { + args: function () { return this.__args; }, - parens:function () { + parens: function () { return this.__parens; } @@ -2353,7 +2353,7 @@ var PlaceHolderLiteralString = define(GenericExpression, { var SQLFunction = define(GenericExpression, { - instance:{ + instance: { /**@lends patio.sql.SQLFunction.prototype*/ /** @@ -2370,7 +2370,7 @@ var SQLFunction = define(GenericExpression, { * @property {Array} args READ ONLY args arguments will be literalized through * {@link patio.Dataset#literal} and placed into the SQL function call. * */ - constructor:function (f) { + constructor: function (f) { var args = argsToArray(arguments).slice(1); this.__f = isInstanceOf(f, Identifier) ? f.value : f, this.__args = args.map(function (a) { return isString(a) ? sql.stringToIdentifier(a) : a; @@ -2385,19 +2385,19 @@ var SQLFunction = define(GenericExpression, { * * @return String the SQL version of the {@link patio.sql.SQLFunction}. */ - toString:function (ds) { + toString: function (ds) { !Dataset && (Dataset = require("./dataset")); ds = ds || new Dataset(); return ds.functionSql(this); }, /**@ignore*/ - getters:{ - f:function () { + getters: { + f: function () { return this.__f; }, - args:function () { + args: function () { return this.__args; } } @@ -2419,7 +2419,7 @@ var NumericExpression = define([ComplexExpression, BitWiseMethods, NumericMethod var OrderedExpression = define(Expression, { - instance:{ + instance: { /**@lends patio.sql.OrderedExpression.prototype*/ /** @@ -2441,7 +2441,7 @@ var OrderedExpression = define(Expression, { * @property {String} [nulls=null] if value is "first" the null values will be first, if "last" then null values * will be last */ - constructor:function (expression, descending, opts) { + constructor: function (expression, descending, opts) { descending = isBoolean(descending) ? descending : true; opts = opts || {}; this.__expression = expression; @@ -2453,22 +2453,22 @@ var OrderedExpression = define(Expression, { /** * @return {patio.sql.OrderedExpression} a copy that is ordered ASC */ - asc:function () { - return new OrderedExpression(this.__expression, false, {nulls:this.__nulls}); + asc: function () { + return new OrderedExpression(this.__expression, false, {nulls: this.__nulls}); }, /** * @return {patio.sql.OrderedExpression} Return a copy that is ordered DESC */ - desc:function () { - return new OrderedExpression(this.__expression, true, {nulls:this.__nulls}); + desc: function () { + return new OrderedExpression(this.__expression, true, {nulls: this.__nulls}); }, /** * * @return {patio.sql.OrderedExpression} an inverted expression, changing ASC to DESC and NULLS FIRST to NULLS LAST. * */ - invert:function () { - return new OrderedExpression(this.__expression, !this.__descending, {nulls:this._static.INVERT_NULLS[this.__nulls] || this.__nulls}); + invert: function () { + return new OrderedExpression(this.__expression, !this.__descending, {nulls: this._static.INVERT_NULLS[this.__nulls] || this.__nulls}); }, /** @@ -2479,38 +2479,38 @@ var OrderedExpression = define(Expression, { * * @return String the SQL version of the {@link patio.sql.OrderedExpression}. */ - toString:function (ds) { + toString: function (ds) { !Dataset && (Dataset = require("./dataset")); ds = ds || new Dataset(); return ds.orderedExpressionSql(this); }, /**@ignore*/ - getters:{ - expression:function () { + getters: { + expression: function () { return this.__expression; }, - descending:function () { + descending: function () { return this.__descending; }, - nulls:function () { + nulls: function () { return this.__nulls; } } }, - static:{ + static: { /**@lends patio.sql.OrderedExpression*/ /** * Hash that contains the inversions for "first" and "last". * @type Object * @default {first:"last", last:"first"} */ - INVERT_NULLS:{first:"last", last:"first"} + INVERT_NULLS: {first: "last", last: "first"} } }).as(sql, "OrderedExpression"); var QualifiedIdentifier = define([GenericExpression, QualifyingMethods], { - instance:{ + instance: { /**@lends patio.sql.QualifiedIdentifier.prototype*/ /** @@ -2526,7 +2526,7 @@ var QualifiedIdentifier = define([GenericExpression, QualifyingMethods], { * @property table READ ONLY the table or schema to qualify the column or table to. * @property column READ ONLY he column or table to qualify. */ - constructor:function (table, column) { + constructor: function (table, column) { this.__table = table; this.__column = column; }, @@ -2539,19 +2539,19 @@ var QualifiedIdentifier = define([GenericExpression, QualifyingMethods], { * * @return String the SQL version of the {@link patio.sql.QualifiedIdentifier}. */ - toString:function (ds) { + toString: function (ds) { !Dataset && (Dataset = require("./dataset")); ds = ds || new Dataset(); return ds.qualifiedIdentifierSql(this); }, /**@ignore*/ - getters:{ - table:function () { + getters: { + table: function () { return this.__table; }, - column:function () { + column: function () { return this.__column; } } @@ -2581,7 +2581,7 @@ var likeElement = function (re) { * @memberOf patio.sql */ var StringExpression = define([ComplexExpression, StringMethods, StringConcatenationMethods, InequalityMethods, NoBooleanInputMethods], { - static:{ + static: { /**@lends patio.sql.StringExpression*/ /** @@ -2609,7 +2609,7 @@ var StringExpression = define([ComplexExpression, StringMethods, StringConcatena * StringExpression.like(sql.a, 'a%', {caseInsensitive : true}) //=> "a" ILIKE 'a%' * StringExpression.like(sql.a, 'a%', /^a/i) //=> "a" LIKE 'a%' OR "a" ~* '^a' */ - like:function (l) { + like: function (l) { var args = argsToArray(arguments, 1); var params = likeElement(l); var likeMap = this.likeMap; @@ -2630,14 +2630,14 @@ var StringExpression = define([ComplexExpression, StringMethods, StringConcatena * LIKE expression. * @type Object */ - likeMap:{"truetrue":'~*', "truefalse":"~", "falsetrue":"ILIKE", "falsefalse":"LIKE"} + likeMap: {"truetrue": '~*', "truefalse": "~", "falsetrue": "ILIKE", "falsefalse": "LIKE"} } }).as(sql, "StringExpression"); var SubScript = define(GenericExpression, { - instance:{ + instance: { /**@lends patio.sql.SubScript.prototype*/ /** @@ -2648,7 +2648,7 @@ var SubScript = define(GenericExpression, { * @param arrCol the SQL array column * @param sub The array of subscripts to use (should be an array of numbers) */ - constructor:function (arrCol, sub) { + constructor: function (arrCol, sub) { //The SQL array column this.__arrCol = arrCol; //The array of subscripts to use (should be an array of numbers) @@ -2659,7 +2659,7 @@ var SubScript = define(GenericExpression, { * Create a new {@link patio.sql.Subscript} appending the given subscript(s) * the the current array of subscripts. */ - addSub:function (sub) { + addSub: function (sub) { return new SubScript(this.__arrCol, this.__sub.concat(sub)); }, @@ -2671,19 +2671,19 @@ var SubScript = define(GenericExpression, { * * @return String the SQL version of the {@link patio.sql.SubScript}. */ - toString:function (ds) { + toString: function (ds) { !Dataset && (Dataset = require("./dataset")); ds = ds || new Dataset(); return ds.subscriptSql(this); }, /**@ignore*/ - getters:{ - f:function () { + getters: { + f: function () { return this.__arrCol; }, - sub:function () { + sub: function () { return this.__sub; } } @@ -2702,7 +2702,7 @@ var addStringMethod = function (op) { }; var LiteralString = define([OrderedMethods, ComplexExpressionMethods, BooleanMethods, NumericMethods, StringMethods, InequalityMethods, AliasMethods], { - instance:{ + instance: { /**@lends patio.sql.LiteralString*/ /** @@ -2719,7 +2719,7 @@ var LiteralString = define([OrderedMethods, ComplexExpressionMethods, BooleanMet * * @param {String} str the literal string. */ - constructor:function (str) { + constructor: function (str) { this.__str = str; } } diff --git a/package.json b/package.json index c7eb3aaf..2edee0f8 100755 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "patio", "description": "Patio query engine and ORM", - "version": "0.2.14", + "version": "0.2.15", "keywords": [ "ORM", "object relation mapper", diff --git a/test/adapters/mysql.test.js b/test/adapters/mysql.test.js index 34b3e459..6fec7860 100644 --- a/test/adapters/mysql.test.js +++ b/test/adapters/mysql.test.js @@ -650,6 +650,7 @@ if (process.env.PATIO_DB === "mysql" || process.env.NODE_ENV === 'test-coverage' assert.deepEqual(sqls, [ "CREATE TABLE items (id integer, list enum('one'))", "DESCRIBE items", + "DESCRIBE items", "ALTER TABLE items CHANGE COLUMN id id int(8) UNSIGNED NULL", "ALTER TABLE items CHANGE COLUMN list list enum('two') NULL" ]); @@ -1313,4 +1314,4 @@ if (process.env.PATIO_DB === "mysql" || process.env.NODE_ENV === 'test-coverage' return patio.disconnect(); }); }); -} \ No newline at end of file +} diff --git a/test/dataset/query.test.js b/test/dataset/query.test.js index 8761d48e..8618691e 100755 --- a/test/dataset/query.test.js +++ b/test/dataset/query.test.js @@ -14,7 +14,7 @@ var it = require('it'), hitch = comb.hitch; -it.describe("Dataset queries",function (it) { +it.describe("Dataset queries", function (it) { patio.identifierInputMethod = null; patio.identifierOutputMethod = null; @@ -471,6 +471,10 @@ it.describe("Dataset queries",function (it) { ['y', 3] ]).sql, "SELECT * FROM test WHERE ((x = 1) AND ((y = 2) OR (y = 3)))"); }); + + it.should("work with hashes", function () { + assert.equal(d1.andGroupedOr({y: "z", z: "y"}).sql, "SELECT * FROM test WHERE ((x = 1) AND ((y = 'z') OR (z = 'y')))"); + }); }); it.describe("#andGroupedAnd", function (it) { @@ -2335,4 +2339,4 @@ it.describe("Dataset queries",function (it) { it.afterAll(comb.hitch(patio, "disconnect")); -}).as(module); +}); \ No newline at end of file