Skip to content

Commit

Permalink
fix(HasOne): Provide initialThroughConstraints for hasOne relationships
Browse files Browse the repository at this point in the history
  • Loading branch information
elpete committed Oct 30, 2020
1 parent 1ee78eb commit 7b3b8d0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
25 changes: 0 additions & 25 deletions models/Relationships/HasMany.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -60,29 +60,4 @@ component extends="quick.models.Relationships.HasOneOrMany" accessors="true" {
return matchMany( argumentCollection = arguments );
}

/**
* Applies the constraints for the final relationship in a `hasManyThrough` chain.
*
* @return void
*/
public QueryBuilder function initialThroughConstraints() {
return variables.related
.newQuery()
.reselectRaw( 1 )
.where( function( q ) {
arrayZipEach(
[
variables.foreignKeys,
variables.localKeys
],
function( foreignKey, localKey ) {
q.where(
variables.related.qualifyColumn( foreignKey ),
variables.parent.retrieveAttribute( localKey )
);
}
);
} );
}

}
25 changes: 25 additions & 0 deletions models/Relationships/HasOneOrMany.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -406,4 +406,29 @@ component extends="quick.models.Relationships.BaseRelationship" accessors="true"
} );
}

/**
* Applies the constraints for the final relationship in a `hasManyThrough` chain.
*
* @return void
*/
public QueryBuilder function initialThroughConstraints() {
return variables.related
.newQuery()
.reselectRaw( 1 )
.where( function( q ) {
arrayZipEach(
[
variables.foreignKeys,
variables.localKeys
],
function( foreignKey, localKey ) {
q.where(
variables.related.qualifyColumn( foreignKey ),
variables.parent.retrieveAttribute( localKey )
);
}
);
} );
}

}

0 comments on commit 7b3b8d0

Please sign in to comment.