Comparing version 0.1.13 to 0.1.14
@@ -1,2 +0,3 @@ | ||
var Where = require("./Where"); | ||
var Helpers = require('./Helpers'); | ||
var Where = require("./Where"); | ||
var aggregate_functions = [ | ||
@@ -183,10 +184,16 @@ "ABS", "CEIL", "FLOOR", "ROUND", | ||
order: function (column, dir) { | ||
sql.order.push({ | ||
c : Array.isArray(column) ? [ get_table_alias(column[0]), column[1] ] : column, | ||
d : (dir == "Z" ? "DESC" : "ASC") | ||
}); | ||
if (Array.isArray(dir)) { | ||
sql.order.push( | ||
Helpers.escapeQuery(Dialect, column, dir) | ||
); | ||
} else { | ||
sql.order.push({ | ||
c : Array.isArray(column) ? [ get_table_alias(column[0]), column[1] ] : column, | ||
d : (dir == "Z" ? "DESC" : "ASC") | ||
}); | ||
} | ||
return this; | ||
}, | ||
build: function () { | ||
var query = [], tmp, i, j, str, select_all = true; | ||
var query = [], tmp, i, j, ord, str, select_all = true; | ||
var having = []; | ||
@@ -316,3 +323,3 @@ | ||
query.push("ON"); | ||
for (ii = 0; ii < sql.from[i].j.length; ii++) { | ||
@@ -358,6 +365,12 @@ if (ii > 0) { | ||
for (i = 0; i < sql.order.length; i++) { | ||
if (Array.isArray(sql.order[i].c)) { | ||
tmp.push(Dialect.escapeId.apply(Dialect, sql.order[i].c) + " " + sql.order[i].d); | ||
} else { | ||
tmp.push(Dialect.escapeId(sql.order[i].c) + " " + sql.order[i].d); | ||
ord = sql.order[i]; | ||
if (typeof ord == 'object') { | ||
if (Array.isArray(ord.c)) { | ||
tmp.push(Dialect.escapeId.apply(Dialect, ord.c) + " " + ord.d); | ||
} else { | ||
tmp.push(Dialect.escapeId(ord.c) + " " + ord.d); | ||
} | ||
} else if (typeof ord == 'string') { | ||
tmp.push(ord); | ||
} | ||
@@ -364,0 +377,0 @@ } |
@@ -9,3 +9,3 @@ { | ||
], | ||
"version": "0.1.13", | ||
"version": "0.1.14", | ||
"license": "MIT", | ||
@@ -12,0 +12,0 @@ "repository": { |
@@ -23,1 +23,16 @@ var common = require('../common'); | ||
); | ||
assert.equal( | ||
common.Select().from('table1').order('col', []).build(), | ||
"SELECT * FROM `table1` ORDER BY col" | ||
); | ||
assert.equal( | ||
common.Select().from('table1').order('?? DESC', ['col']).build(), | ||
"SELECT * FROM `table1` ORDER BY `col` DESC" | ||
); | ||
assert.equal( | ||
common.Select().from('table1').order('ST_Distance(??, ST_GeomFromText(?,4326))', ['geopoint', 'POINT(-68.3394 27.5578)']).build(), | ||
"SELECT * FROM `table1` ORDER BY ST_Distance(`geopoint`, ST_GeomFromText('POINT(-68.3394 27.5578)',4326))" | ||
); |
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
50194
1670