Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sqb

Package Overview
Dependencies
Maintainers
1
Versions
174
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sqb - npm Package Compare versions

Comparing version 0.11.0 to 0.12.0

lib/connect/Connection.js

16

lib/index.js

@@ -25,6 +25,3 @@ /* SQB

const Serializer = require('./serializer');
const DbPool = require('./connect/pool');
const Connection = require('./connect/connection');
const DatasetCache = require('./connect/datasetcache').DatasetCache;
const DatasetStream = require('./connect/datasetstream');
const Pool = require('./connect/Pool');
const types = require('./types');

@@ -40,6 +37,3 @@ const sqbexport = require('./sqbexport');

Serializer: Serializer,
DbPool: DbPool,
Connection: Connection,
DatasetCache: DatasetCache,
DatasetStream: DatasetStream,
Pool: Pool,

@@ -96,6 +90,6 @@ SqlObject: SqlObject,

* @param {String|Object} config
* @return {DbPool}
* @return {Pool}
*/
pool: function(config) {
return new DbPool(config);
createPool: function(config) {
return new Pool(config);
},

@@ -102,0 +96,0 @@

@@ -50,3 +50,3 @@ /* SQB

}
if (row[key] instanceof Number &&
if (typeof row[key] === 'number' &&
options.fetchAsString.indexOf(Number) >= 0) {

@@ -53,0 +53,0 @@ row[key] = String(row[key]);

@@ -15,3 +15,3 @@ /* SQB

use: function(plugin) {
if (typeof plugin === 'object')
if (typeof plugin === 'object' && items.indexOf(plugin) < 0)
items.push(plugin);

@@ -24,3 +24,3 @@ },

createConnector: function(config) {
createDriver: function(config) {
var plugin;

@@ -30,4 +30,4 @@ var result;

plugin = items[i];
if (typeof plugin.createConnector === 'function') {
result = plugin.createConnector(config);
if (typeof plugin.createDriver === 'function') {
result = plugin.createDriver(config);
if (result) return result;

@@ -57,9 +57,4 @@ }

}
},
jsonStringify: function(obj) {
const stringify = this.stringify;
return stringify ? stringify(obj) : JSON.stringify(obj);
}
};

@@ -35,5 +35,3 @@ /* SQB

const proto = DeleteQuery.prototype = {};
Object.setPrototypeOf(proto, Query.prototype);
proto.constructor = DeleteQuery;
Object.setPrototypeOf(DeleteQuery.prototype, Query.prototype);

@@ -45,3 +43,3 @@ /**

*/
proto.clearFrom = function() {
DeleteQuery.prototype.clearFrom = function() {
this._tables = [];

@@ -56,3 +54,3 @@ return this;

*/
proto.clearWhere = function() {
DeleteQuery.prototype.clearWhere = function() {
this._where = new ConditionGroup();

@@ -67,3 +65,3 @@ return this;

*/
proto.from = function(table) {
DeleteQuery.prototype.from = function(table) {
if (table) {

@@ -81,5 +79,5 @@ this._table = table.isRaw ? table : new Table(String(table));

*/
proto.where = function(condition) {
DeleteQuery.prototype.where = function(condition) {
this._where.add.apply(this._where, arguments);
return this;
};

@@ -51,5 +51,3 @@ /* SQB

const proto = InsertQuery.prototype = {};
Object.setPrototypeOf(proto, ReturningQuery.prototype);
proto.constructor = InsertQuery;
Object.setPrototypeOf(InsertQuery.prototype, ReturningQuery.prototype);

@@ -61,3 +59,3 @@ /**

*/
proto.into = function(table) {
InsertQuery.prototype.into = function(table) {
if (!table) return this;

@@ -73,3 +71,3 @@ this._table = table.isRaw ? table : new Table(String(table));

*/
proto.values = function(values) {
InsertQuery.prototype.values = function(values) {
var out;

@@ -76,0 +74,0 @@ if (!values)

@@ -30,7 +30,6 @@ /* SQB

const proto = Query.prototype = {};
Object.setPrototypeOf(proto, SqlObject.prototype);
proto.constructor = Query;
Object.setPrototypeOf(Query.prototype, SqlObject.prototype);
Query.prototype.constructor = Query;
proto.generate = function(config, values) {
Query.prototype.generate = function(config, values) {
const serializer = (config && config.isSerializer) ? config :

@@ -41,3 +40,3 @@ new Serializer(config);

proto.action = function(value) {
Query.prototype.action = function(value) {
this._action = value;

@@ -47,3 +46,3 @@ return this;

proto.clientId = function(value) {
Query.prototype.clientId = function(value) {
this._clientId = value;

@@ -53,3 +52,3 @@ return this;

proto.module = function(value) {
Query.prototype.module = function(value) {
this._module = value;

@@ -59,3 +58,3 @@ return this;

proto.params = function(obj) {
Query.prototype.params = function(obj) {
if (typeof obj !== 'object')

@@ -67,3 +66,3 @@ throw new ArgumentError('Invalid argument');

proto.then = function(options, callback) {
Query.prototype.then = function(options, callback) {
if (typeof options === 'function') {

@@ -77,4 +76,4 @@ callback = options;

proto.execute = function(options, callback) {
const dbobj = this.connection || this.dbpool;
Query.prototype.execute = function(options, callback) {
const dbobj = this.connection || this.pool;
if (!dbobj)

@@ -81,0 +80,0 @@ throw new Error('This query is not executable');

@@ -29,11 +29,6 @@ /* SQB

const proto = ReturningQuery.prototype = {
get isSelect() {
return this.type === 'select';
}
};
Object.setPrototypeOf(proto, Query.prototype);
proto.constructor = ReturningQuery;
Object.setPrototypeOf(ReturningQuery.prototype, Query.prototype);
ReturningQuery.prototype.constructor = ReturningQuery;
proto.returning = function(obj) {
ReturningQuery.prototype.returning = function(obj) {
if (obj) {

@@ -40,0 +35,0 @@ if (typeof obj !== 'object')

@@ -42,3 +42,3 @@ /* SQB

const proto = SelectQuery.prototype = {
SelectQuery.prototype = {
get isSelect() {

@@ -48,4 +48,4 @@ return this.type === 'select';

};
Object.setPrototypeOf(proto, Query.prototype);
proto.constructor = SelectQuery;
Object.setPrototypeOf(SelectQuery.prototype, Query.prototype);
SelectQuery.prototype.constructor = SelectQuery;

@@ -57,3 +57,3 @@ /**

*/
proto.clearColumns = function() {
SelectQuery.prototype.clearColumns = function() {
this._columns = [];

@@ -68,3 +68,3 @@ return this;

*/
proto.clearFrom = function() {
SelectQuery.prototype.clearFrom = function() {
this._tables = [];

@@ -79,3 +79,3 @@ return this;

*/
proto.clearJoin = function() {
SelectQuery.prototype.clearJoin = function() {
this._joins = [];

@@ -90,3 +90,3 @@ return this;

*/
proto.clearGroupBy = function() {
SelectQuery.prototype.clearGroupBy = function() {
this._groupby = [];

@@ -101,3 +101,3 @@ return this;

*/
proto.clearOrderBy = function() {
SelectQuery.prototype.clearOrderBy = function() {
this._orderby = [];

@@ -112,3 +112,3 @@ return this;

*/
proto.clearWhere = function() {
SelectQuery.prototype.clearWhere = function() {
this._where = new ConditionGroup();

@@ -123,3 +123,3 @@ return this;

*/
proto.columns = function(column) {
SelectQuery.prototype.columns = function(column) {
const self = this;

@@ -144,3 +144,3 @@ var arg;

*/
proto.from = function(table) {
SelectQuery.prototype.from = function(table) {
this.clearFrom();

@@ -162,3 +162,3 @@ var arg;

*/
proto.join = function(join) {
SelectQuery.prototype.join = function(join) {
var arg;

@@ -181,3 +181,3 @@ for (var i = 0; i < arguments.length; i++) {

*/
proto.where = function(condition) {
SelectQuery.prototype.where = function(condition) {
this._where.add.apply(this._where, arguments);

@@ -193,3 +193,3 @@ return this;

*/
proto.groupBy = function(field) {
SelectQuery.prototype.groupBy = function(field) {
this.clearGroupBy();

@@ -211,3 +211,3 @@ var arg;

*/
proto.orderBy = function(field) {
SelectQuery.prototype.orderBy = function(field) {
this.clearOrderBy();

@@ -229,3 +229,3 @@ var arg;

*/
proto.as = function(alias) {
SelectQuery.prototype.as = function(alias) {
this._alias = alias;

@@ -241,3 +241,3 @@ return this;

*/
proto.limit = function(limit) {
SelectQuery.prototype.limit = function(limit) {
this._limit = limit;

@@ -253,3 +253,3 @@ return this;

*/
proto.offset = function(offset) {
SelectQuery.prototype.offset = function(offset) {
this._offset = offset;

@@ -264,10 +264,9 @@ return this;

*/
proto.onFetchRow = function(callback) {
SelectQuery.prototype.onFetchRow = function(callback) {
if (!callback) return this;
if (typeof callback !== 'function')
throw new ArgumentError('Invalid argument. Function type required');
this._onfetchrow = this._onfetchrow = [];
this._onfetchrow.push(callback);
this._onFetchRow = this._onFetchRow = [];
this._onFetchRow.push(callback);
return this;
};

@@ -37,5 +37,3 @@ /* SQB

const proto = UpdateQuery.prototype = {};
Object.setPrototypeOf(proto, ReturningQuery.prototype);
proto.constructor = UpdateQuery;
Object.setPrototypeOf(UpdateQuery.prototype, ReturningQuery.prototype);

@@ -47,3 +45,3 @@ /**

*/
proto.clearWhere = function() {
UpdateQuery.prototype.clearWhere = function() {
this._where = new ConditionGroup();

@@ -59,3 +57,3 @@ return this;

*/
proto.set = function(values) {
UpdateQuery.prototype.set = function(values) {
if (!values) return this;

@@ -83,5 +81,5 @@ if (values.isRaw)

*/
proto.where = function(condition) {
UpdateQuery.prototype.where = function(condition) {
this._where.add.apply(this._where, arguments);
return this;
};

@@ -24,3 +24,3 @@ /* SQB

function isNumeric(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
return isFinite(n) && +n === n;
}

@@ -49,4 +49,4 @@

const proto = Serializer.prototype = {
// noinspection JSMethodCanBeStatic
Serializer.prototype = {
get isSerializer() {

@@ -84,3 +84,3 @@ return true;

};
proto.constructor = Serializer;
Serializer.prototype.constructor = Serializer;

@@ -92,6 +92,6 @@ /**

* @param {Array|Object} [inputValues]
* @return {{sql: string, params: (Object|Array) }}
* @return {Object}
* @public
*/
proto.generate = function(query, inputValues) {
Serializer.prototype.generate = function(query, inputValues) {
assert.ok(['select', 'insert', 'update', 'delete'].indexOf(query.type) >= 0,

@@ -125,3 +125,3 @@ 'Invalid argument');

this.config = owner.config;
this.prmGen = owner.prmGen;
this._prmGen = owner._prmGen;
} else {

@@ -131,3 +131,3 @@ this.config = Object.assign({}, owner._config);

this.outParamsCache = {};
this.prmGen = {generator: 0};
this._prmGen = {generator: 0};
this.reservedWords = [

@@ -145,17 +145,14 @@ 'schema', 'table', 'field', 'index', 'acs', 'ascending', 'dsc',

const proto2 = SerializerInstance.prototype = {};
proto2.constructor = SerializerInstance;
/**
*
* @param {String} s
* @param {String} str
* @return {boolean}
*/
proto2.isReserved = function(s) {
s = String(s).toLowerCase();
if (this.reservedWords.indexOf(s) >= 0)
SerializerInstance.prototype.isReserved = function(str) {
str = String(str).toLowerCase();
if (this.reservedWords.indexOf(str) >= 0)
return true;
if (this.pluginSerializer &&
typeof this.pluginSerializer.isReserved === 'function')
return this.pluginSerializer.isReserved(s);
return this.pluginSerializer.isReserved(str);
};

@@ -169,3 +166,3 @@

*/
proto2.generate = function(query, inputValues) {
SerializerInstance.prototype.generate = function(query, inputValues) {
this.query = query;

@@ -177,3 +174,2 @@ this.inputValues = inputValues;

//noinspection JSUnusedLocalSymbols
/**

@@ -186,3 +182,3 @@ * Serialize Select query

*/
proto2.serializeSelect = function(query) {
SerializerInstance.prototype.serializeSelect = function(query) {
const self = this;

@@ -243,3 +239,3 @@ var out = 'select';

*/
proto2.serializeInsert = function(query) {
SerializerInstance.prototype.serializeInsert = function(query) {
assert.ok(query && query._table &&

@@ -260,27 +256,22 @@ ['raw', 'table'].indexOf(query._table.type) >= 0,

var s;
if (objValues) {
if (['raw', 'select'].indexOf(objValues.type) >= 0) {
s = __serialize(self, objValues, {section: 'insert.values'});
if (s)
out += (objValues.type === 'select' ? '\n' : ' ') + s;
if (['raw', 'select'].indexOf(objValues.type) >= 0) {
out += (objValues.type === 'select' ? '\n' : ' ') +
__serialize(self, objValues, {section: 'insert.values'});
} else {
out += ' values (';
self._prmIdx = 0;
} else {
out += ' values (';
self._prmIdx = 0;
// Iterate over columns
const iinf = {
section: 'insert.values',
index: 0
};
query._columns.forEach(function(col, idx) {
const field = col.field.toUpperCase();
const val = objValues[field];
iinf.index = idx;
s = serializeValue(self, val, iinf);
if (s)
out += (idx ? ', ' : '') + s;
});
out += ')';
}
// Iterate over columns
const iinf = {
section: 'insert.values',
index: 0
};
query._columns.forEach(function(col, idx) {
const field = col.field.toUpperCase();
const val = objValues[field];
iinf.index = idx;
out += (idx ? ', ' : '') +
serializeValue(self, val, iinf);
});
out += ')';
}

@@ -290,2 +281,3 @@ if (query._returning) {

{section: 'insert.returning'});
/* istanbul ignore else */
if (s)

@@ -304,3 +296,3 @@ out += '\n' + s;

*/
proto2.serializeUpdate = function(query) {
SerializerInstance.prototype.serializeUpdate = function(query) {
assert.ok(query && query._table &&

@@ -329,2 +321,3 @@ ['raw', 'table'].indexOf(query._table.type) >= 0,

const s = serializeUpdateValue(self, key, values[key], iinf);
/* istanbul ignore else */
if (s)

@@ -345,2 +338,3 @@ out += (idx ? ',\n' : '') + s;

{section: 'update.returning'});
/* istanbul ignore else */
if (s)

@@ -360,3 +354,3 @@ out += '\n' + s;

*/
proto2.serializeDelete = function(query) {
SerializerInstance.prototype.serializeDelete = function(query) {
assert.ok(query && query._table &&

@@ -377,3 +371,2 @@ ['raw', 'table'].indexOf(query._table.type) >= 0,

//noinspection JSUnusedLocalSymbols,JSUnusedGlobalSymbols
/**

@@ -387,3 +380,3 @@ * Serializes array of column names comes after 'Select'

*/
proto2.serializeColumns = function(columns, inf) {
SerializerInstance.prototype.serializeColumns = function(columns, inf) {
if (!(columns && columns.length)) return '';

@@ -413,3 +406,2 @@ var out = '';

// noinspection JSUnusedGlobalSymbols
/**

@@ -423,16 +415,15 @@ * Serializes array of column names comes after 'Select'

*/
proto2.serializeColumn = function(column, inf) {
if (!column) return '';
SerializerInstance.prototype.serializeColumn = function(column, inf) {
assert.ok(['column', 'raw', 'case', 'select'].indexOf(column.type) >= 0,
'Invalid object for serializing column');
const s = __serialize(this, column, inf);
//noinspection JSUnresolvedVariable
return column.type === 'select' ?
'(' + s + ')' + (column._alias ?
' ' + (this.isReserved(column._alias) ? '"' + column._alias +
'"' : column._alias) : '') :
'(' + s + ')' +
(column._alias ?
' ' + (this.isReserved(column._alias) ? '"' + column._alias +
'"' : column._alias)
: '') :
s;
};
//noinspection JSMethodCanBeStatic,JSUnusedLocalSymbols
/**

@@ -446,4 +437,5 @@ * Serializes single field name

*/
proto2.serializeFieldName = function(field, inf) {
return (field.table ? field.table + '.' : '') + field.field +
SerializerInstance.prototype.serializeFieldName = function(field, inf) {
return (field.table ? field.table + '.' : '') +
(this.isReserved(field.field) ? '"' + field.field + '"' : field.field) +
(field.alias ? ' ' +

@@ -454,3 +446,2 @@ (this.isReserved(field.alias) ? '"' + field.alias +

//noinspection JSUnusedLocalSymbols,JSUnusedGlobalSymbols
/**

@@ -464,3 +455,3 @@ * Serializes tables names comes after 'From'

*/
proto2.serializeFrom = function(tables, inf) {
SerializerInstance.prototype.serializeFrom = function(tables, inf) {
if (!(tables && tables.length)) return '';

@@ -476,3 +467,3 @@ var out = '';

const lf = s.length > 40;
if (item.type === 'select') { //noinspection JSUnresolvedVariable
if (item.type === 'select') {
s = '(' + (lf ? '\n\t' : '') + s + ')' + (lf ? '\b' : '') +

@@ -488,3 +479,2 @@ (item._alias ? ' ' + item._alias : '');

//noinspection JSUnusedLocalSymbols,JSUnusedGlobalSymbols
/**

@@ -498,3 +488,3 @@ * Serializes array of Joins

*/
proto2.serializeJoins = function(joins, inf) {
SerializerInstance.prototype.serializeJoins = function(joins, inf) {
if (!joins || !joins.length) return '';

@@ -506,2 +496,3 @@ const self = this;

const s = serializeJoin(self, j, iinf);
/* istanbul ignore else */
if (s)

@@ -514,3 +505,2 @@ out += (out ? '\n' : '') + s;

//noinspection JSUnusedLocalSymbols,JSUnusedGlobalSymbols
/**

@@ -524,3 +514,3 @@ * Serializes single Join

*/
proto2.serializeJoin = function(join, inf) {
SerializerInstance.prototype.serializeJoin = function(join, inf) {
var out;

@@ -555,2 +545,3 @@ switch (join.joinType) {

const lf = s.length > 40;
/* istanbul ignore else */
if (s) {

@@ -571,3 +562,2 @@ if (join.table.type === 'select') {

//noinspection JSMethodCanBeStatic,JSUnusedLocalSymbols
/**

@@ -582,7 +572,6 @@ * Serialize Raw object

// eslint-disable-next-line
proto2.serializeRaw = function(raw, inf) {
return raw ? raw.text || '' : '';
SerializerInstance.prototype.serializeRaw = function(raw, inf) {
return (raw && raw.text) || '';
};
//noinspection JSMethodCanBeStatic,JSUnusedLocalSymbols
/**

@@ -596,3 +585,3 @@ * Serializes single table name

*/
proto2.serializeTableName = function(table, inf) {
SerializerInstance.prototype.serializeTableName = function(table, inf) {
return (table.schema ? table.schema + '.' : '') +

@@ -603,3 +592,2 @@ table.table +

//noinspection JSUnusedLocalSymbols,JSUnusedGlobalSymbols
/**

@@ -613,3 +601,3 @@ * Serializes single table name

*/
proto2.serializeWhere = function(group, inf) {
SerializerInstance.prototype.serializeWhere = function(group, inf) {
const s = serializeConditionGroup(this, group, inf);

@@ -619,3 +607,2 @@ return s ? 'where ' + s : '';

//noinspection JSUnusedLocalSymbols
/**

@@ -629,3 +616,3 @@ * Serializes condition group

*/
proto2.serializeConditionGroup = function(group, inf) {
SerializerInstance.prototype.serializeConditionGroup = function(group, inf) {
if (!group || !group.length) return '';

@@ -635,3 +622,3 @@ const self = this;

var line = '';
var logop = 'and';
var logop;
var k = 0;

@@ -644,4 +631,5 @@ var lf = 0;

'Invalid object used as Condition');
logop = item.logicalOperator || logop;
logop = item.logicalOperator;
var s = __serialize(self, item, iinf);
/* istanbul ignore else */
if (s) {

@@ -662,2 +650,3 @@ if (item.type === 'conditiongroup') s = '(' + s + ')';

});
/* istanbul ignore else */
if (line)

@@ -668,3 +657,2 @@ out += (out ? '\n' + (lf === 1 ? '\t' : '') : '') + line;

//noinspection JSUnusedLocalSymbols
/**

@@ -678,3 +666,3 @@ * Serializes condition

*/
proto2.serializeCondition = function(item, inf) {
SerializerInstance.prototype.serializeCondition = function(item, inf) {
const self = this;

@@ -689,3 +677,2 @@ var str;

const outParams = self.outParams;
var operator = item.operator.toLowerCase();

@@ -698,3 +685,3 @@ var s;

prmValue = self.inputValues && self.inputValues[prm];
} else if (self.strictParams && !item.value.isSqlObject) {
} else if (self.config.strictParams && !item.value.isSqlObject) {
prm = self.prmGen();

@@ -712,7 +699,5 @@ prmValue = item.value;

} else if ((operator === 'like' || operator === '!like' ||
operator === 'not like') && !prm &&
Array.isArray(item.value) &&
(s = item.value.join()) &&
((s.indexOf('%') >= 0) || s.indexOf('?') >= 0)) {
} else if ((['like', '!like', 'not like'].indexOf(operator) >= 0) &&
!prm && Array.isArray(item.value) &&
(s = item.value.join())) {
s = '(';

@@ -736,2 +721,3 @@ item.value.forEach(function(v, i) {

/* istanbul ignore else */
if (s)

@@ -742,3 +728,3 @@ str += ' ' + operator + ' ' + s;

proto2.serializeParam = function(prm, prmValue, multi) {
SerializerInstance.prototype.serializeParam = function(prm, prmValue, multi) {
const valIsArray = Array.isArray(prmValue);

@@ -753,6 +739,6 @@ const outParams = this.outParams;

outParams[prm + '1'] = (valIsArray ? prmValue[0] : prmValue);
outParams[prm + '2'] = (valIsArray ? prmValue[1] : null);
outParams[prm + '2'] = (valIsArray ? prmValue[1] : prmValue);
} else {
s = ':' + prm;
outParams[prm] = prmValue || null;
outParams[prm] = prmValue == null ? null : prmValue;
}

@@ -765,6 +751,6 @@ break;

outParams.push(valIsArray ? prmValue[0] : prmValue);
outParams.push(valIsArray ? prmValue[1] : null);
outParams.push(valIsArray ? prmValue[1] : prmValue);
} else {
s = '$' + (outParams.length + 1);
outParams.push(prmValue || null);
outParams.push(prmValue == null ? null : prmValue);
}

@@ -776,6 +762,6 @@ break;

outParams.push(valIsArray ? prmValue[0] : prmValue);
outParams.push(valIsArray ? prmValue[1] : null);
outParams.push(valIsArray ? prmValue[1] : prmValue);
} else {
s = '?';
outParams.push(prmValue || null);
outParams.push(prmValue == null ? null : prmValue);
}

@@ -787,3 +773,2 @@ break;

//noinspection JSUnusedLocalSymbols,JSUnusedGlobalSymbols
/**

@@ -797,4 +782,4 @@ * Serializes any value

*/
proto2.serializeValue = function(val, inf) {
if (val === null || val === undefined)
SerializerInstance.prototype.serializeValue = function(val, inf) {
if (val == null)
return 'null';

@@ -830,4 +815,2 @@ const self = this;

}
if (typeof val === 'string')
return serializeStringValue(self, val, inf);
if (isNumeric(val))

@@ -842,3 +825,2 @@ return String(val);

//noinspection JSMethodCanBeStatic, JSUnusedLocalSymbols,JSUnusedGlobalSymbols
/**

@@ -852,7 +834,6 @@ * Serializes string value

*/
proto2.serializeStringValue = function(val, inf) {
SerializerInstance.prototype.serializeStringValue = function(val, inf) {
return '\'' + (val || '').replace('\'', '\'\'') + '\'';
};
//noinspection JSMethodCanBeStatic, JSUnusedLocalSymbols,JSUnusedGlobalSymbols
/**

@@ -866,3 +847,3 @@ * Serializes Date value

*/
proto2.serializeDateValue = function(date, inf) {
SerializerInstance.prototype.serializeDateValue = function(date, inf) {
const d = date.getDate();

@@ -882,3 +863,2 @@ const m = date.getMonth() + 1;

//noinspection JSUnusedLocalSymbols,JSUnusedGlobalSymbols
/**

@@ -892,3 +872,3 @@ * Serializes Array value

*/
proto2.serializeArrayValue = function(arr, inf) {
SerializerInstance.prototype.serializeArrayValue = function(arr, inf) {
var str = '';

@@ -902,3 +882,2 @@ const self = this;

//noinspection JSUnusedLocalSymbols,JSUnusedGlobalSymbols
/**

@@ -912,7 +891,6 @@ * Serializes array of 'group by' columns

*/
proto2.serializeGroupBy = function(columns, inf) {
SerializerInstance.prototype.serializeGroupBy = function(columns, inf) {
return serializeColumns(this, columns, {section: 'groupby'});
};
//noinspection JSUnusedLocalSymbols,JSUnusedGlobalSymbols
/**

@@ -926,3 +904,3 @@ * Serializes array of 'order by' columns

*/
proto2.serializeOrderBy = function(columns, inf) {
SerializerInstance.prototype.serializeOrderBy = function(columns, inf) {
if (!(columns && columns.length)) return '';

@@ -946,3 +924,2 @@ const self = this;

// noinspection JSUnusedGlobalSymbols
/**

@@ -957,3 +934,3 @@ * Serializes single value for Update query

*/
proto2.serializeUpdateValue = function(key, value, inf) {
SerializerInstance.prototype.serializeUpdateValue = function(key, value, inf) {
const self = this;

@@ -969,3 +946,2 @@ var s;

//noinspection JSUnusedLocalSymbols
/**

@@ -979,3 +955,3 @@ * Serializes Case expression

*/
proto2.serializeCase = function(obj, inf) {
SerializerInstance.prototype.serializeCase = function(obj, inf) {
if (obj._expressions.length) {

@@ -1008,3 +984,2 @@ const self = this;

//noinspection JSUnusedLocalSymbols,JSUnusedGlobalSymbols
/**

@@ -1018,3 +993,3 @@ * Serializes "returning"

*/
proto2.serializeReturning = function(bindings, inf) {
SerializerInstance.prototype.serializeReturning = function(bindings, inf) {
if (!bindings) return '';

@@ -1041,4 +1016,4 @@ var out = '';

proto2.prmGen = function() {
return 'generated_parameter_' + this.prmGen.generator++;
SerializerInstance.prototype.prmGen = function() {
return 'generated_parameter_' + this._prmGen.generator++;
};

@@ -1045,0 +1020,0 @@

@@ -16,3 +16,2 @@ /* SQB

//noinspection JSMethodCanBeStatic
raw: function(str) {

@@ -22,3 +21,2 @@ return new Raw(str);

//noinspection JSMethodCanBeStatic
join: function(table) {

@@ -28,3 +26,2 @@ return new Join(Join.Type.innerJoin, table);

//noinspection JSMethodCanBeStatic
innerJoin: function(table) {

@@ -34,3 +31,2 @@ return new Join(Join.Type.innerJoin, table);

//noinspection JSMethodCanBeStatic,JSUnusedGlobalSymbols
leftJoin: function(table) {

@@ -40,3 +36,2 @@ return new Join(Join.Type.leftJoin, table);

//noinspection JSMethodCanBeStatic,JSUnusedGlobalSymbols
leftOuterJoin: function(table) {

@@ -46,3 +41,2 @@ return new Join(Join.Type.leftOuterJoin, table);

//noinspection JSMethodCanBeStatic,JSUnusedGlobalSymbols
rightJoin: function(table) {

@@ -52,3 +46,2 @@ return new Join(Join.Type.rightJoin, table);

//noinspection JSMethodCanBeStatic,JSUnusedGlobalSymbols
rightOuterJoin: function(table) {

@@ -58,3 +51,2 @@ return new Join(Join.Type.rightOuterJoin, table);

//noinspection JSMethodCanBeStatic,JSUnusedGlobalSymbols
outerJoin: function(table) {

@@ -64,3 +56,2 @@ return new Join(Join.Type.outerJoin, table);

//noinspection JSMethodCanBeStatic,JSUnusedGlobalSymbols
fullOuterJoin: function(table) {

@@ -70,3 +61,2 @@ return new Join(Join.Type.fullOuterJoin, table);

//noinspection JSMethodCanBeStatic,JSUnusedGlobalSymbols
case: function() {

@@ -73,0 +63,0 @@ return new Case();

@@ -31,7 +31,5 @@ /* SQB

const proto = Case.prototype = {};
Object.setPrototypeOf(proto, SqlObject.prototype);
proto.constructor = Case;
Object.setPrototypeOf(Case.prototype, SqlObject.prototype);
proto.when = function(condition) {
Case.prototype.when = function(condition) {
if (condition && arguments.length) {

@@ -44,3 +42,3 @@ this._condition = Object.create(ConditionGroup.prototype);

proto.then = function(value) {
Case.prototype.then = function(value) {
if (this._condition)

@@ -54,3 +52,3 @@ this._expressions.push({

proto.as = function(alias) {
Case.prototype.as = function(alias) {
this._alias = alias;

@@ -60,6 +58,5 @@ return this;

//noinspection ReservedWordAsName
proto.else = function(value) {
Case.prototype.else = function(value) {
this._elseValue = value;
return this;
};

@@ -37,5 +37,3 @@ /* SQB

const proto = Column.prototype = {};
Object.setPrototypeOf(proto, SqlObject.prototype);
proto.constructor = Column;
Object.setPrototypeOf(Column.prototype, SqlObject.prototype);

@@ -52,3 +52,3 @@ /* SQB

const proto = Condition.prototype = {
Condition.prototype = {
get field() {

@@ -94,4 +94,4 @@ return this._field;

};
Object.setPrototypeOf(proto, SqlObject.prototype);
proto.constructor = Condition;
Object.setPrototypeOf(Condition.prototype, SqlObject.prototype);
Condition.prototype.constructor = Condition;

@@ -98,0 +98,0 @@ Condition.Operators = [

@@ -35,3 +35,3 @@ /* SQB

const proto = ConditionGroup.prototype = {
ConditionGroup.prototype = {
get length() {

@@ -41,4 +41,4 @@ return this._items.length;

};
Object.setPrototypeOf(proto, SqlObject.prototype);
proto.constructor = ConditionGroup;
Object.setPrototypeOf(ConditionGroup.prototype, SqlObject.prototype);
ConditionGroup.prototype.constructor = ConditionGroup;

@@ -50,3 +50,3 @@ /**

*/
proto.add = function(item) {
ConditionGroup.prototype.add = function(item) {
if (!(item && arguments.length)) return this;

@@ -75,4 +75,3 @@ var c;

self._items.push(c);
} else if (typeof arg[0] === 'string' || (
['select', 'raw'].indexOf(arg[0].type) >= 0)) {
} else {
c = Object.create(Condition.prototype);

@@ -82,11 +81,10 @@ Condition.apply(c, arg);

self._items.push(c);
} else throw new TypeError('Invalid argument');
}
}
} else if (arg === 'and' || arg === 'or') {
logop = arg;
} else if (arg.type === 'raw') {
//noinspection JSUndefinedPropertyAssignment
} else if (arg && arg.type === 'raw') {
arg.logicalOperator = logop;
self._items.push(arg);
} else if (arg)
} else if (arg != null)
throw new TypeError('Invalid argument');

@@ -96,4 +94,4 @@ }

proto.item = function(index) {
ConditionGroup.prototype.item = function(index) {
return this._items[index];
};

@@ -43,7 +43,5 @@ /* SQB

const proto = Join.prototype = {};
Object.setPrototypeOf(proto, SqlObject.prototype);
proto.constructor = Join;
Object.setPrototypeOf(Join.prototype, SqlObject.prototype);
proto.on = function(conditions) {
Join.prototype.on = function(conditions) {
this.conditions.add.apply(this.conditions, arguments);

@@ -50,0 +48,0 @@ return this;

@@ -42,4 +42,2 @@ /* SQB

const proto = Order.prototype = {};
Object.setPrototypeOf(proto, SqlObject.prototype);
proto.constructor = Order;
Object.setPrototypeOf(Order.prototype, SqlObject.prototype);

@@ -31,3 +31,3 @@ /* SQB

const proto = Raw.prototype = {
Raw.prototype = {
get isRaw() {

@@ -37,3 +37,3 @@ return this.type === 'raw';

};
Object.setPrototypeOf(proto, SqlObject.prototype);
proto.constructor = Raw;
Object.setPrototypeOf(Raw.prototype, SqlObject.prototype);

@@ -22,8 +22,2 @@ /* SQB

const proto = SqlObject.prototype = {
get isSqlObject() {
return true;
}
};
proto.constructor = SqlObject.prototype;

@@ -37,4 +37,3 @@ /* SQB

const proto = TableName.prototype = {};
Object.setPrototypeOf(proto, SqlObject.prototype);
proto.constructor = TableName;
Object.setPrototypeOf(TableName.prototype, SqlObject.prototype);

@@ -9,9 +9,2 @@ /* SQB

const DatasetMode = {
NONE: 0,
STATIC: 1,
CURSOR: 2,
CACHED: 3
};
const ParamType = {

@@ -24,5 +17,4 @@ COLON: 1,

module.exports = {
DatasetMode: DatasetMode,
ParamType: ParamType
};
{
"name": "sqb",
"description": "Plugin-driven, multi-dialect SQL query builder and Database connection framework for JavaScript",
"version": "0.11.0",
"version": "0.12.0",
"author": "Panates Ltd.",

@@ -19,9 +19,9 @@ "contributors": [

"multi-dialect",
"database",
"framework"
"database"
],
"dependencies": {
"debug": "^3.1.0",
"doublylinked": "^1.0.5",
"errorex": "^1.0.6",
"generic-pool": "^3.2.0",
"lightning-pool": "^1.0.2",
"putil-flattentext": "^1.1.1",

@@ -31,8 +31,8 @@ "putil-isplainobject": "^1.0.1",

"putil-promisify": "^1.1.0",
"putil-taskqueue": "^1.1.0",
"putil-waterfall": "^1.1.1"
"putil-taskqueue": "^1.3.1",
"putil-waterfall": "^1.1.2"
},
"devDependencies": {
"babel-eslint": "^8.0.1",
"eslint": "^4.9.0",
"babel-eslint": "^8.0.2",
"eslint": "^4.11.0",
"eslint-config-google": "^0.9.1",

@@ -39,0 +39,0 @@ "istanbul": "^0.4.5",

@@ -33,3 +33,3 @@ # SQB

- node >= 6.x
- node >= 4.x

@@ -36,0 +36,0 @@ ### License

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc