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.12 to 0.0.13

25

lib/Select.js

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

var aggregate_fun = function (fun) {
return function (column, alias) {
return function () {
if (arguments.length === 0) {

@@ -27,3 +27,11 @@ fun_stack.push(fun);

}
return this.fun(fun, column, alias);
var column = Array.prototype.slice.apply(arguments);
var alias = (column.length > 1 && typeof column[column.length - 1] == "string" ? column.pop() : null);
if (column.length && Array.isArray(column[0])) {
column = column[0].concat(column.slice(1));
}
return this.fun(fun, column.length && column[0] ? column : '*', alias);
};

@@ -40,7 +48,13 @@ };

count : aggregate_fun("COUNT"),
abs : aggregate_fun("ABS"),
ceil : aggregate_fun("CEIL"),
floor : aggregate_fun("FLOOR"),
round : aggregate_fun("ROUND"),
avg : aggregate_fun("AVG"),
min : aggregate_fun("MIN"),
max : aggregate_fun("MAX"),
sum : aggregate_fun("SUM"),
avg : aggregate_fun("AVG"),
count : aggregate_fun("COUNT"),

@@ -165,2 +179,5 @@ fun: function (fun, column, alias) {

str += sql.from[i].select[j].c.map(function (el) {
if (typeof el != "string") {
return el;
}
if (sql.from.length == 1) {

@@ -167,0 +184,0 @@ return Dialect.escapeId(el);

2

package.json

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

],
"version": "0.0.12",
"version": "0.0.13",
"license": "MIT",

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

@@ -23,1 +23,16 @@ var common = require('../common');

);
assert.equal(
common.Select().from('table1').round('col1', 2).build(),
"SELECT ROUND(`col1`, 2) FROM `table1`"
);
assert.equal(
common.Select().from('table1').round().build(),
"SELECT ROUND(*) FROM `table1`"
);
assert.equal(
common.Select().from('table1').round('col1', 3, 'x').build(),
"SELECT ROUND(`col1`, 3) AS `x` FROM `table1`"
);

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

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

@@ -18,0 +18,0 @@ );

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