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

db-migrate-base

Package Overview
Dependencies
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

db-migrate-base - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

85

index.js

@@ -307,3 +307,2 @@ var util = require('util');

log.warn( 'This calling convention of insert is deprecated' );
columnNameArray = valueArray;

@@ -389,8 +388,31 @@ valueArray = callback;

update: function(tableName, columnNameArray, valueArray, ids, callback) {
update: function(tableName, valueArray, ids, callback) {
if (columnNameArray.length !== valueArray.length) {
var columnNameArray = {};
if ( arguments > 4 && arguments[1].length !== arguments[2].length) {
return callback(new Error('The number of columns does not match the number of values.'));
} else if ( arguments > 4 ) {
columnNameArray = valueArray;
valueArray = ids;
ids = callback;
callback = arguments[4];
}
else {
var names;
if( util.isArray(valueArray) ) {
names = Object.keys(valueArray[0]);
}
else {
names = Object.keys(valueArray);
}
for( var i = 0; i < names.length; ++i ) {
columnNameArray[names[i]] = names[i];
}
}
var sql = util.format('UPDATE ' + this._escapeDDL + '%s' + this._escapeDDL + ' SET ', tableName );

@@ -412,3 +434,3 @@

sql += ' ' + buildWhereClause(ids);
sql = sql.substring( 0, sql.length - 2 ) + ' ' + this.buildWhereClause(ids);
return this.runSql(sql).nodeify(callback);

@@ -420,3 +442,3 @@ },

var sql = 'SELECT ' + this.escapeDDL(column) + ' FROM ' +
this.escapeDDL(tableName) + ' ' + buildWhereClause(id);
this.escapeDDL(tableName) + ' ' + this.buildWhereClause(id);

@@ -533,3 +555,3 @@ return this.runSql(sql)

return this.runSql(sql + buildWhereClause(ids)).nodeify(callback);
return this.runSql(sql + this.buildWhereClause(ids)).nodeify(callback);
},

@@ -565,5 +587,7 @@

}
else if(typeof(ids) === 'string' || ids.length === 1) {
else if(typeof(ids) === 'string' || ids.length === 1 ||
typeof(ids) === 'number') {
var id = (util.isArray(ids)) ? ids[0] : ids;
searchClause += 'WHERE id = ' + id;
searchClause += 'WHERE id = ' + this._escapeString + id +
this._escapeString;
}

@@ -577,2 +601,18 @@ else if (util.isArray(ids) && typeof(ids[0]) === 'object'){

for (var column in ids) {
var columnKeys = Object.keys(ids[column]);
if ( columnKeys.length === 1 ) {
var _column = {
name: columnKeys[0],
value: ids[column][columnKeys[0]]
};
column = _column;
}
else {
column = ids[column];
}
column.name = column.name || 'id',

@@ -582,5 +622,6 @@ column.operator = column.operator || '=',

if (!column.searchValue) {
if (!column.value) {
return Promise.reject('column ' + column.name + ' was entered without a searchValue.');
return Promise.reject('column ' + column.name +
' was entered without a search value.');
}

@@ -595,10 +636,11 @@

searchClause += ' (SELECT ' + this._escapeDDL + column.selector +
this._escapeDDL + ' FROM ' + this._escapeDDL +
column.searchValue.table + this._escapeDDL +
buildWhereClause(column.searchValue.column) + ')';
searchClause += ' (SELECT ' + this._escapeDDL +
column.selector + this._escapeDDL + ' FROM ' +
this._escapeDDL + column.searchValue.table + this._escapeDDL +
this.buildWhereClause(column.searchValue.column) + ')';
}
else {
searchClause += ' (' + this._escapeString + column.searchValue + this._escapeString + ')';
searchClause += ' (' + this._escapeString + column.value +
this._escapeString + ')';
}

@@ -609,3 +651,16 @@

}
else if( typeof(ids) === 'object' ) {
var key = Object.keys( ids );
var preLink = '';
searchClause += 'WHERE ';
for( var i = 0; i < key.length; ++i ) {
searchClause += preLink + this._escapeDDL + key[i] + this._escapeDDL +
' = ' + this._escapeString + ids[key[i]] + this._escapeString;
preLink = ' AND ';
}
}
return searchClause;

@@ -612,0 +667,0 @@ },

2

package.json
{
"name": "db-migrate-base",
"version": "1.2.1",
"version": "1.2.2",
"description": "db-migrate base driver",

@@ -5,0 +5,0 @@ "main": "index.js",

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