Comparing version 0.15.4 to 0.15.6
@@ -23,19 +23,19 @@ !function () { | ||
// id counter for the root resource | ||
, _id: 0 | ||
// is set to true as soon the join statement | ||
// is set to true as soon the join statement | ||
// was applied to the root resource | ||
, _joinApplied: false | ||
// is set to true as soon the filter statement | ||
// is set to true as soon the filter statement | ||
// was applied to the root resource | ||
, _filterApplied: false | ||
// is set to true as soon the order statement | ||
// is set to true as soon the order statement | ||
// was applied to the root resource | ||
, _orderingApplied: false | ||
// is set to true as soon the current resource | ||
// is set to true as soon the current resource | ||
// was prepared for selection | ||
@@ -72,4 +72,4 @@ , _selectApplied: false | ||
// returns an id which is used to priorize the order stetements | ||
@@ -278,3 +278,3 @@ , orderId: { get: function() { | ||
* @param <Boolean> isSubQuery is this query part of the select statement of another query? | ||
* @param <Boolean> skipSelect ? | ||
* @param <Boolean> skipSelect ? | ||
*/ | ||
@@ -327,4 +327,4 @@ , prepare: function(skipSelect, isSubQuery) { | ||
/* | ||
* check which children must be selected. this means to select | ||
* all parents if required. | ||
* check which children must be selected. this means to select | ||
* all parents if required. | ||
*/ | ||
@@ -362,8 +362,8 @@ , _selectChildren: function(resource) { | ||
} | ||
// we need to apply our filter to all parent queries | ||
// execpt for the root resource (thats happened already | ||
// execpt for the root resource (thats happened already | ||
// using the prepareRootQuery method). | ||
// all subselects need to be filtered in the same way as | ||
// all subselects need to be filtered in the same way as | ||
// their children are filtered | ||
@@ -373,3 +373,3 @@ if (resource.hasFiltersForTheRootResource() && resource.hasParent() && !resource.getParent().isRootResource()) { | ||
this.applyFiltersToParents(resource.getParent(), resource, [], resource); | ||
} | ||
} | ||
} | ||
@@ -390,9 +390,9 @@ | ||
/* | ||
* check if this resource is selected, if yes, make sure all | ||
* check if this resource is selected, if yes, make sure all | ||
* parents are selected using their primary keys. | ||
*/ | ||
, prepareSubqueries: function() { | ||
var parent; | ||
var parent, parentFilter, filter; | ||
if (this.isSelected() && !this.selectApplied()) { | ||
@@ -412,3 +412,20 @@ parent = this.getParent(); | ||
// select the parent referenced field | ||
if (this.referencedParentColumn) this.query.select.push(ORM.alias('____id____', this.referencedParentTable, this.referencedParentColumn)); | ||
if (this.referencedParentColumn) { | ||
this.query.select.push(ORM.alias('____id____', this.referencedParentTable, this.referencedParentColumn)); | ||
// if this table is a reference from the parent to this table | ||
// we need to copy the filter of the parent to our query, else we will | ||
// load a shitload of records without any use for them | ||
// this is a desing flaw and a hack :( | ||
parentFilter = parent.getQuery().filter[this.referencedParentTable]; | ||
if (parentFilter) { | ||
if (!this.getQuery().filter[this.referencedParentTable]) this.getQuery().filter[this.referencedParentTable] = {}; | ||
filter = this.getQuery().filter[this.referencedParentTable]; | ||
Object.keys(parentFilter).forEach(function(key) { | ||
filter[key] = parentFilter[key]; | ||
}.bind(this)); | ||
} | ||
} | ||
else this.query.select.push(ORM.alias('____id____', this.referencedParentTable, this.referencedParentColumn)); | ||
@@ -454,3 +471,3 @@ | ||
if (debug) log.debug('[%s] applying filters on %s to the parent %s ...'.yellow, sourceResource.name, sourceResource.name, currentTargetResource.name); | ||
@@ -462,3 +479,3 @@ | ||
// aka: do we need to add the join from the parent to this resource? | ||
if (!currentTargetResource._appliedJoins[lastTargetResource.name]) { | ||
if (!currentTargetResource._appliedJoins[lastTargetResource.name]) { | ||
if (debug) log.debug('[%s] adding sub-join from %s to %s ...'.cyan, sourceResource.name, lastTargetResource.name, currentTargetResource.name); | ||
@@ -559,3 +576,3 @@ | ||
* thi is called on the root resource only and | ||
* only after the root query was executed (so there | ||
* only after the root query was executed (so there | ||
* is a set witrh ids) | ||
@@ -574,3 +591,3 @@ */ | ||
/* | ||
* group a resource by my primarykeys, this is used by the | ||
* group a resource by my primarykeys, this is used by the | ||
* querycompiler | ||
@@ -601,6 +618,6 @@ */ | ||
* prepare the root query based on the configuration of this | ||
* resource. this function calls the parent until it reaches | ||
* the root resource. applies filters, selects, orders. | ||
* resource. this function calls the parent until it reaches | ||
* the root resource. applies filters, selects, orders. | ||
* this method is called on each of the children of the root | ||
* resource, so we need to check what was already joined and | ||
* resource, so we need to check what was already joined and | ||
* what not. | ||
@@ -628,3 +645,3 @@ */ | ||
// query, do left joins | ||
this.addJoinsToRootResource(true); | ||
this.addJoinsToRootResource(true); | ||
@@ -662,3 +679,3 @@ // apply orderings all the way up to the root resource | ||
* for all parent resources | ||
*/ | ||
*/ | ||
, addOrderingToRootResource: function() { | ||
@@ -678,3 +695,3 @@ if (!this.isRootResource() && !this.orderingApplied()) { | ||
*/ | ||
, applyOrdering: function(targetResource) { | ||
, applyOrdering: function(targetResource) { | ||
this.order.forEach(function(instruction) { | ||
@@ -696,3 +713,3 @@ targetResource.getQuery().order.push({ | ||
* for all parent resources | ||
*/ | ||
*/ | ||
, addFiltersToRootResource: function() { | ||
@@ -720,3 +737,3 @@ if (!this.isRootResource() && !this.filterApplied()) { | ||
// normal filters | ||
if (this.filters && Object.keys(this.filters).length) { | ||
if (this.filters && Object.keys(this.filters).length) { | ||
targetFilter = targetResource.query.filter[name]; | ||
@@ -735,3 +752,3 @@ | ||
/* | ||
* add the current joins statment to the root query, call the | ||
* add the current joins statment to the root query, call the | ||
* same method on all parents until we're at the root resource | ||
@@ -738,0 +755,0 @@ * itself |
{ | ||
"name" : "ee-orm" | ||
, "description" : "ORM for postgres and mysql. Loads and saves referenced entites, executes complex queries, supports joins, transactions, complex database clusters, connection pooling and much more. No conventions. MIT Licence" | ||
, "version" : "0.15.4" | ||
, "version" : "0.15.6" | ||
, "homepage" : "https://github.com/eventEmitter/ee-orm" | ||
@@ -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
321226
38
6227