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.0.28 to 0.0.29

38

lib/Select.js

@@ -50,3 +50,10 @@ var Where = require("./Where");

if (fields) {
sql.from[sql.from.length - 1].select = (Array.isArray(fields) ? fields : Array.prototype.slice.apply(arguments));
if (!sql.from[sql.from.length - 1].select) {
sql.from[sql.from.length - 1].select = [];
}
sql.from[sql.from.length - 1].select = sql.from[sql.from.length - 1].select.concat(
Array.isArray(fields)
? fields
: Array.prototype.slice.apply(arguments)
);
}

@@ -60,2 +67,16 @@ return this;

},
as: function (alias) {
var idx = sql.from.length - 1;
if (sql.from[idx].select.length) {
var idx2 = sql.from[idx].select.length - 1;
if (typeof sql.from[idx].select[idx2] == "string") {
sql.from[idx].select[idx2] = { c: sql.from[idx].select[idx2] };
}
sql.from[idx].select[sql.from[idx].select.length - 1].a = alias || null;
}
return this;
},
fun: function (fun, column, alias) {

@@ -169,5 +190,6 @@ if (!Array.isArray(sql.from[sql.from.length - 1].select)) {

// if (typeof sql.from[i].select[0] != "object") continue;
//
for (j = 0; j < sql.from[i].select.length; j++) {
if (typeof sql.from[i].select[j] == "string") {
if (typeof sql.from[i].select[j] == "string" ) {
if (sql.from.length == 1) {

@@ -181,2 +203,12 @@ tmp.push(Dialect.escapeId(sql.from[i].select[j]));

if (typeof sql.from[i].select[j] == "object") {
if (!sql.from[i].select[j].f && sql.from[i].select[j].c) {
if (sql.from.length == 1) {
tmp.push(Dialect.escapeId(sql.from[i].select[j].c));
} else {
tmp.push(Dialect.escapeId(sql.from[i].a, sql.from[i].select[j].c));
}
if (sql.from[i].select[j].a) {
tmp[tmp.length - 1] += " AS " + Dialect.escapeId(sql.from[i].select[j].a);
}
}
if (sql.from[i].select[j].having) {

@@ -191,2 +223,4 @@ having.push(Dialect.escapeId(sql.from[i].select[j].having));

if (!sql.from[i].select[j].f) continue;
str = sql.from[i].select[j].f + "(";

@@ -193,0 +227,0 @@

2

package.json

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

],
"version": "0.0.28",
"version": "0.0.29",
"license": "MIT",

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

@@ -15,2 +15,17 @@ var common = require('../common');

assert.equal(
common.Select().from('table1').select('id', 'name').as('label').build(),
"SELECT `id`, `name` AS `label` FROM `table1`"
);
assert.equal(
common.Select().from('table1').select('id', 'name').select('title').as('label').build(),
"SELECT `id`, `name`, `title` AS `label` FROM `table1`"
);
assert.equal(
common.Select().from('table1').select('id', 'name').as('label').select('title').build(),
"SELECT `id`, `name` AS `label`, `title` FROM `table1`"
);
assert.equal(
common.Select().from('table1').select([ 'id', 'name' ]).build(),

@@ -17,0 +32,0 @@ "SELECT `id`, `name` FROM `table1`"

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