-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New
hasManyDeep
and hasManyDeepBuilder
relationships.
`hasManyThrough` needs some work to be more performant and produce expected queries. `hasManyDeep` is a ground up rewrite alongside `hasManyThrough`. Eventually we will add a `belongsToDeep` and hopefully even patch `hasManyThrough` and `belongsToThrough` through the new relationships.
- Loading branch information
Showing
22 changed files
with
914 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
component accessors="true" { | ||
|
||
property name="relationName" type="string"; | ||
property name="through" type="array"; | ||
property name="foreignKeys" type="array"; | ||
property name="localKeys" type="array"; | ||
|
||
public HasManyDeepBuilder function init( required any parent, required string relationMethodName ) { | ||
variables.parent = arguments.parent; | ||
variables.relationMethodName = arguments.relationMethodName; | ||
|
||
variables.through = []; | ||
variables.foreignKeys = []; | ||
variables.localKeys = []; | ||
|
||
return this; | ||
} | ||
|
||
public HasManyDeepBuilder function throughEntity( | ||
required string entityName, | ||
required any foreignKey, | ||
required any localKey | ||
) { | ||
variables.through.append( arguments.entityName ); | ||
variables.foreignKeys.append( arguments.foreignKey ); | ||
variables.localKeys.append( arguments.localKey ); | ||
return this; | ||
} | ||
|
||
public HasManyDeepBuilder function throughPivotTable( | ||
required string tableName, | ||
required any foreignKey, | ||
required any localKey | ||
) { | ||
variables.through.append( arguments.tableName ); | ||
variables.foreignKeys.append( arguments.foreignKey ); | ||
variables.localKeys.append( arguments.localKey ); | ||
return this; | ||
} | ||
|
||
public HasManyDeepBuilder function throughPolymorphicEntity( | ||
required string entityName, | ||
required string type, | ||
required any foreignKey, | ||
required any localKey | ||
) { | ||
variables.through.append( arguments.entityName ); | ||
variables.foreignKeys.append( [ arguments.type, arguments.foreignKey ] ); | ||
variables.localKeys.append( arguments.localKey ); | ||
return this; | ||
} | ||
|
||
public HasManyDeep function toRelated( | ||
required string relationName, | ||
required any foreignKey, | ||
required any localKey | ||
) { | ||
variables.foreignKeys.append( arguments.foreignKey ); | ||
variables.localKeys.append( arguments.localKey ); | ||
|
||
return variables.parent.hasManyDeep( | ||
relationName = arguments.relationName, | ||
through = variables.through, | ||
foreignKeys = variables.foreignKeys, | ||
localKeys = variables.localKeys, | ||
relationMethodName = variables.relationMethodName | ||
); | ||
} | ||
|
||
public HasManyDeep function toPolymorphicRelated( | ||
required string relationName, | ||
required string type, | ||
required any foreignKey, | ||
required any localKey | ||
) { | ||
variables.foreignKeys.append( [ arguments.type, arguments.foreignKey ] ); | ||
variables.localKeys.append( arguments.localKey ); | ||
|
||
return variables.parent.hasManyDeep( | ||
relationName = arguments.relationName, | ||
through = variables.through, | ||
foreignKeys = variables.foreignKeys, | ||
localKeys = variables.localKeys, | ||
relationMethodName = variables.relationMethodName | ||
); | ||
} | ||
|
||
} |
Oops, something went wrong.