ee-query-builder
Advanced tools
Comparing version 0.2.7 to 0.2.8
@@ -33,2 +33,6 @@ !function(){ | ||
, reference: function(command, paramaters) { | ||
return '= '+this._escapeId(command.entity)+'.'+this._escapeId(command.column); | ||
} | ||
@@ -42,3 +46,3 @@ , in: function(command, paramaters) { | ||
if (type.function(values.isQuery)) { | ||
return ' IN ('+this._queryBuilder._render('query', this._queryBuilder._prepareQueryFilter(values), paramaters).SQLString+')'; | ||
return ' IN ('+this._queryBuilder._render('query', this._queryBuilder._prepareQuery(values), paramaters).SQLString+')'; | ||
} | ||
@@ -62,3 +66,3 @@ else { | ||
if (type.function(values.isQuery)) { | ||
return ' NOT IN ('+this._queryBuilder._render('query', this._queryBuilder._prepareQueryFilter(values), paramaters).SQLString+')'; | ||
return ' NOT IN ('+this._queryBuilder._render('query', this._queryBuilder._prepareQuery(values), paramaters).SQLString+')'; | ||
} | ||
@@ -65,0 +69,0 @@ else { |
@@ -55,3 +55,3 @@ !function(){ | ||
*/ | ||
, _render: function(mode, query, parameters){ | ||
, _render: function(mode, query, parameters) { | ||
@@ -303,2 +303,23 @@ // maybe we get already some parmeters from a parent query .. | ||
case 'object': | ||
if (instruction.byArray) { | ||
var statement | ||
, index; | ||
// ordering by custom values | ||
if (this._type === 'postgres') { | ||
statement = 'CASE'; | ||
index = 0; | ||
(instruction.desc ? instruction.byArray.reverse() : instruction.byArray).forEach(function(item) { | ||
statement += ' WHEN '+this._escapeId(instruction.entity)+'.'+this._escapeId(instruction.property)+' = '+this._escape(item)+' THEN '+(++index) | ||
}.bind(this)); | ||
statement += ' ELSE '+(++index)+' END ' | ||
instructions.push(statement); | ||
} | ||
else if (this._type === 'mysql') { | ||
instructions.push('FIELD('+this._escapeId(instruction.entity)+'.'+this._escapeId(instruction.property)+', '+(instruction.desc ? instruction.byArray.reverse() : instruction.byArray).join(', ')+')'); | ||
} | ||
else throw new Error('byArray ordering on databases of type «'+this._type+'» not implemented!'); | ||
} | ||
instructions.push(this._escapeId(instruction.entity)+'.'+this._escapeId(instruction.property) + (instruction.desc ? ' DESC' : ' ASC')); | ||
@@ -317,2 +338,3 @@ break; | ||
/** | ||
@@ -345,3 +367,3 @@ * the _renderFilter() method creates an sql where statement from | ||
case 'object': | ||
selects.push('('+this._render('query', selector.query, parameters).SQLString+') as '+this._escapeId(selector.alias || 'undefined')); | ||
selects.push('('+this._render('query', this._prepareQuery(selector.query), parameters).SQLString+') as '+this._escapeId(selector.alias || 'undefined')); | ||
break; | ||
@@ -395,3 +417,3 @@ | ||
// returns it | ||
return this._escapeId(entity)+'.'+this._escapeId(property)+' = ('+this._render('query', this._prepareQueryFilter(filter), parameters).SQLString+')'; | ||
return this._escapeId(entity)+'.'+this._escapeId(property)+' = ('+this._render('query', this._prepareQuery(filter), parameters).SQLString+')'; | ||
} | ||
@@ -435,4 +457,4 @@ else { | ||
*/ | ||
, _prepareQueryFilter: function(filter){ | ||
var resource = filter.getRootResource(); | ||
, _prepareQuery: function(query){ | ||
var resource = query.getRootResource(); | ||
@@ -462,3 +484,3 @@ resource.setSelectMode(); | ||
else if (type.function(command.value.isQuery) && command.value.isQuery()) { | ||
return entity+this._escapeId(property)+' '+this._operators[command.operator]+ ' (' + this._render('query', this._prepareQueryFilter(command.value), parameters).SQLString +')'; | ||
return entity+this._escapeId(property)+' '+this._operators[command.operator]+ ' (' + this._render('query', this._prepareQuery(command.value), parameters).SQLString +')'; | ||
} | ||
@@ -465,0 +487,0 @@ else { |
{ | ||
"name" : "ee-query-builder" | ||
, "description" : "query builder for ee-orm" | ||
, "version" : "0.2.7" | ||
, "version" : "0.2.8" | ||
, "homepage" : "https://github.com/eventEmitter/ee-query-builder" | ||
@@ -6,0 +6,0 @@ , "author" : "Michael van der Weg <michael@eventemitter.com> (http://eventemitter.com/)" |
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
22717
519