Socket
Socket
Sign inDemoInstall

mg-dbop

Package Overview
Dependencies
18
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.9 to 0.0.10

51

dbOp.js

@@ -39,2 +39,4 @@ /**

const tableFromSql = [];
for (let t in joinStruct) {

@@ -55,3 +57,9 @@ const left = t.split(".");

this.tables[leftTable.name] = leftTable;
this.fromSql += "`" + leftTable.name + "` " + leftTable.alias + ",";
tableFromSql.push({
alias: leftTable.alias,
from: "`" + leftTable.name + "` " + leftTable.alias,
joins: []
});
}

@@ -67,3 +75,9 @@

this.tables[rightTable.name] = rightTable;
this.fromSql += "`" + rightTable.name + "` " + rightTable.alias + ",";
tableFromSql.push({
alias: rightTable.alias,
from: "`" + rightTable.name + "` " + rightTable.alias,
joins: []
});
}

@@ -82,3 +96,2 @@

if (typeof leftJoinStruct != "undefined") {
this.fromSql = this.fromSql.substring(0, this.fromSql.length - 1);

@@ -124,3 +137,8 @@ for (let t in leftJoinStruct) {

// Create the LEFT JOIN
this.fromSql += " LEFT JOIN " + rightTable.name + " " + rightTable.alias + " ON " + leftTable.alias + ".`" + left[2] + "` = " + rightTable.alias + ".`" + right[2] + "`";
for ( let t of tableFromSql ){
if ( t.alias == leftTable.alias ){
t.joins.push( " LEFT JOIN " + rightTable.name + " " + rightTable.alias + " ON " + leftTable.alias + ".`" + left[2] + "` = " + rightTable.alias + ".`" + right[2] + "`" );
break;
}
}
}

@@ -130,2 +148,15 @@ }

// Now we need to create the FROM SQL
for ( let t of tableFromSql ){
this.fromSql += t.from;
if ( t.joins.length > 0 ){
this.fromSql += t.joins.join(" ");
}
this.fromSql += ",";
}
if (this.fromSql.endsWith(",")) {
this.fromSql = this.fromSql.substring(0, this.fromSql.length - 1);
}
if (this.whereSql.endsWith(" AND ")) {

@@ -135,9 +166,5 @@ this.whereSql = this.whereSql.substring(0, this.whereSql.lastIndexOf(" AND"));

if (this.fromSql.endsWith(",")) {
this.fromSql = this.fromSql.substring(0, this.fromSql.length - 1);
}
return this;
}
selectAll() {

@@ -168,3 +195,2 @@ // Go through the core tables

select(statement) {

@@ -175,3 +201,2 @@ this.selectSql = statement;

/**

@@ -195,3 +220,2 @@ * statement should be a legal SQL statement, with the alias and ? for the prepared statement;

whereOR(statement, values) {

@@ -211,3 +235,2 @@ if (this.whereSql.length == 0) {

orderby(statement) {

@@ -294,6 +317,6 @@ this.orderbySql = " ORDER BY " + statement;

for (let column in table.desc.columns) {
if (_.has(req.query, table.alias + "." + column) ) {
if (_.has(req.query, table.alias + "." + column)) {
this.where(table.alias + ".`" + column + "` = ?", req.query[table.alias + "." + column]);
filteredColumns[table.alias + "." + column] = true;
} else if ( _.has(req.query, column)) {
} else if (_.has(req.query, column)) {
this.where(table.alias + ".`" + column + "` = ?", req.query[column]);

@@ -300,0 +323,0 @@ filteredColumns[table.alias + "." + column] = true;

@@ -314,2 +314,4 @@ /**

data[fieldData] = null;
} else if ( typeof data[fieldData].getMonth === 'function' ){
// this is a date object so we don't need to worry
} else {

@@ -327,2 +329,4 @@ const parts = data[fieldData].split("-");

data[fieldData] = null;
} else if ( typeof data[fieldData].getMonth === 'function' ){
// this is a date object so we don't need to worry
} else {

@@ -329,0 +333,0 @@ const dateTime = data[fieldData].split(" ");

{
"name": "mg-dbop",
"private" : false,
"version": "0.0.9",
"version": "0.0.10",
"homepage": "https://github.com/MacLaurinGroup/dbOp",

@@ -6,0 +6,0 @@ "description": "Query builder, and validator, for MySQL and node that utilizes the underlying table to provide a level of checking",

@@ -247,2 +247,4 @@ ## dbOp

* 2019-03-28
* Fixed bug with the order to which the LEFT JOIN is added into the SQL
* 2019-03-10

@@ -249,0 +251,0 @@ * Allow null to be set for varchar/text fields

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc