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

sql-query

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sql-query - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

41

lib/Select.js

@@ -105,7 +105,24 @@ var Where = require("./Where");

var a, f = from_id, t;
if (arguments.length == 3) {
from.j = [ from_id, sql.from[sql.from.length - 1].a, to_table ];
a = sql.from[sql.from.length - 1].a;
t = to_table;
} else {
from.j = [ from_id, get_table_alias(to_table), to_id ];
a = get_table_alias(to_table);
t = to_id;
}
from.j = [];
if (f.length && t.length) {
if (Array.isArray(f) && Array.isArray(t) && f.length == t.length) {
for (i = 0; i < f.length; i++) {
from.j.push([f[i], a, t[i]]);
}
} else {
from.j.push([f, a, t]);
}
} else {
throw new Error();
}
sql.from.push(from);

@@ -298,11 +315,17 @@ return this;

if (i > 0) {
query.push(
"ON " +
Dialect.escapeId(sql.from[i].a, sql.from[i].j[0]) +
" = " +
Dialect.escapeId(sql.from[i].j[1], sql.from[i].j[2])
);
query.push("ON");
for (ii = 0; ii < sql.from[i].j.length; ii++) {
if (ii > 0) {
query.push("AND");
}
query.push(
Dialect.escapeId(sql.from[i].a, sql.from[i].j[ii][0]) +
" = " +
Dialect.escapeId(sql.from[i].j[ii][1], sql.from[i].j[ii][2])
);
}
if (i < sql.from.length - 1) {
query.push(")");
query.push(")");
}

@@ -309,0 +332,0 @@ }

@@ -9,3 +9,3 @@ {

],
"version": "0.1.3",
"version": "0.1.4",
"license": "MIT",

@@ -12,0 +12,0 @@ "repository": {

@@ -96,1 +96,7 @@ var common = require('../common');

);
assert.equal(
common.Select().from('table1')
.from('table2',['id2a', 'id2b'], 'table1', ['id1a', 'id1b']).count('id').build(),
"SELECT COUNT(`t2`.`id`) FROM `table1` `t1` JOIN `table2` `t2` ON `t2`.`id2a` = `t1`.`id1a` AND `t2`.`id2b` = `t1`.`id1b`"
);

Sorry, the diff of this file is not supported yet

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