Permalink
Browse files

Adds more aggregate functions to the several drivers

Supports alias to be able to have similar functions with the same name
across drivers
  • Loading branch information...
1 parent 0cd38eb commit d7d610b739a146965305a3537896a9b3cb188eea @dresende committed Apr 3, 2013
View
@@ -65,8 +65,16 @@ function AggregateFunctions(opts) {
};
for (var i = 0; i < opts.driver.aggregate_functions.length; i++) {
- proto[opts.driver.aggregate_functions[i].toLowerCase()] = appendFunction(opts.driver.aggregate_functions[i].toLowerCase());
+ addAggregate(proto, opts.driver.aggregate_functions[i], appendFunction);
}
return proto;
}
+
+function addAggregate(proto, fun, builder) {
+ if (Array.isArray(fun)) {
+ proto[fun[0].toLowerCase()] = builder((fun[1] || fun[0]).toLowerCase());
+ } else {
+ proto[fun.toLowerCase()] = builder(fun.toLowerCase());
+ }
+}
View
@@ -20,6 +20,9 @@ function Driver(config, connection, opts) {
this.aggregate_functions = [ "ABS", "CEIL", "FLOOR", "ROUND",
"AVG", "MIN", "MAX",
+ "LOG", "LOG2", "LOG10", "EXP", "POWER",
+ "ACOS", "ASIN", "ATAN", "COS", "SIN", "TAN",
+ "CONV", [ "RANDOM", "RAND" ], "RADIANS", "DEGREES",
"SUM", "COUNT" ];
}
@@ -19,6 +19,9 @@ function Driver(config, connection, opts) {
this.aggregate_functions = [ "ABS", "CEIL", "FLOOR", "ROUND",
"AVG", "MIN", "MAX",
+ "LOG", "EXP", "POWER",
+ "ACOS", "ASIN", "ATAN", "COS", "SIN", "TAN",
+ "RANDOM", "RADIANS", "DEGREES",
"SUM", "COUNT" ];
}
@@ -13,6 +13,9 @@ function Driver(config, connection, opts) {
this.aggregate_functions = [ "ABS", "CEIL", "FLOOR", "ROUND",
"AVG", "MIN", "MAX",
+ "LOG", "EXP", "POWER",
+ "ACOS", "ASIN", "ATAN", "COS", "SIN", "TAN",
+ "RANDOM", "RADIANS", "DEGREES",
"SUM", "COUNT" ];
}
Driver.prototype.sync = function (opts, cb) {
@@ -19,6 +19,7 @@ function Driver(config, connection, opts) {
this.aggregate_functions = [ "ABS", "ROUND",
"AVG", "MIN", "MAX",
+ "RANDOM",
"SUM", "COUNT" ];
}

0 comments on commit d7d610b

Please sign in to comment.