Comparing version 0.3.19 to 0.3.20
@@ -11,3 +11,2 @@ !function(){ | ||
, QueryBuilderBuilder = require('./QueryBuilderBuilder') | ||
, clone = require('clone') | ||
, log = require('ee-log'); | ||
@@ -14,0 +13,0 @@ |
@@ -6,3 +6,2 @@ !function(){ | ||
, log = require('ee-log') | ||
, clone = require('clone') | ||
, Arguments = require('ee-arguments') | ||
@@ -19,4 +18,20 @@ , type = require('ee-types') | ||
// clone the filter object but not its contents | ||
var clone = function(input) { | ||
var copy; | ||
if (type.object(input)) { | ||
copy = {}; | ||
Object.keys(input).forEach(function(key){ | ||
copy[key] = input[key]; | ||
}); | ||
return copy; | ||
} | ||
else return input; | ||
} | ||
module.exports = new Class({ | ||
@@ -382,7 +397,52 @@ | ||
Object.keys(filter).forEach(function(property){ | ||
var queryColum; | ||
if (!query.filter[tablename]) query.filter[tablename] = {}; | ||
query.filter[tablename][property] = filter[property]; | ||
if (filter[property] && type.function(filter[property].isQuery)) { | ||
// get the corret identifier for the subquery | ||
queryColum = this._findColumnForIdentifier(property); | ||
query.filter[tablename][queryColum.name] = filter[property]; | ||
// select the first primary if nothing was selected by the user | ||
if (!filter[property]._resource.query.select.length) { | ||
filter[property]._resource.query.select.push(filter[property]._definition.primaryKeys[0]); | ||
} | ||
} | ||
else query.filter[tablename][property] = filter[property]; | ||
}.bind(this)); | ||
} | ||
, _findColumnForIdentifier: function(propertyName) { | ||
var resultingColumn; | ||
Object.keys(this._definition.columns).some(function(colName) { | ||
column = this._definition.columns[colName]; | ||
if (column.name === propertyName) return resultingColumn = column, true; | ||
if (column.referencedTable === propertyName) return resultingColumn = column, true; | ||
if (column.mapsTo && column.mapsTo.length) { | ||
column.mapsTo.some(function(mapping){ | ||
var id = mapping.aliasName || mapping.name; | ||
if(id === propertyName) return resultingColumn = column, true; | ||
}.bind(this)); | ||
if (resultingColumn) return true; | ||
} | ||
if (column.belongsTo && column.belongsTo.length) { | ||
column.belongsTo.some(function(belongsTo){ | ||
var id = belongsTo.aliasName || belongsTo.name; | ||
if(id === propertyName) return resultingColumn = column, true; | ||
}.bind(this)); | ||
if (resultingColumn) return true; | ||
} | ||
}.bind(this)); | ||
return resultingColumn; | ||
} | ||
, _parseSelect: function(query, tablename, select) { | ||
@@ -389,0 +449,0 @@ select.forEach(function(item){ |
{ | ||
"name" : "ee-orm" | ||
, "description" : "An easy to use ORM for node.js. Supports eager loading, complex queries, joins, transactions, complex database clusters & connection pooling." | ||
, "version" : "0.3.19" | ||
, "version" : "0.3.20" | ||
, "homepage" : "https://github.com/eventEmitter/ee-orm" | ||
@@ -26,3 +26,2 @@ , "author" : "Michael van der Weg <michael@eventemitter.com> (http://eventemitter.com/)" | ||
, "ee-arguments" : "1.0.x" | ||
, "clone" : "0.1.x" | ||
, "ee-db-cluster" : "0.1.x" | ||
@@ -29,0 +28,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
175889
8
3326
- Removedclone@0.1.x
- Removedclone@0.1.19(transitive)