Comparing version 0.0.12 to 0.0.13
@@ -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); |
@@ -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 @@ ); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30860
1090