Allow constraining allowed relations in @whereConditions and @whereHasConditions#1896
Allow constraining allowed relations in @whereConditions and @whereHasConditions#1896
@whereConditions and @whereHasConditions#1896Conversation
# Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md # src/WhereConditions/WhereConditionsServiceProvider.php
@whereConditions and @whereHasConditions
|
@LastDragon-ru please review. |
LastDragon-ru
left a comment
There was a problem hiding this comment.
Sorry for delay. Looks good I think 👍
…ions' into constrain-where-conditions-relations
| @@ -129,10 +155,18 @@ input QueryPeopleWhereWhereConditionsRelation { | |||
| "Additional condition logic." | |||
| condition: QueryPeopleWhereWhereConditions | |||
There was a problem hiding this comment.
I realized that this is nonsensical when combined with columnsEnum. The allowed columns of the original model are used for the relations as well.
We need to find a solution that either has a separate input that allows columns as strings for relations, or an even more sophisticated solution that has enums for the relations. Configuration could look like this:
@whereConditions(relations: [
{ name: "friends", columns: ["name", "age"] }
{ name: "friends.friends", columns: ["name", "age"] }
])
input QueryPeopleWhereWhereConditionsRelation {
friends: QueryPeopleWhereWhereConditionsFriendsConditions
friendsFriends: QueryPeopleWhereWhereConditionsFriendsFriendsConditions
}
input QueryPeopleWhereWhereConditionsFriendsConditions{
column: QueryPeopleWhereWhereConditionsFriendsColumn
operator: SQLOperator = EQ
value: Mixed
AND: [QueryPeopleWhereWhereConditionsFriendsConditions!]
OR: [QueryPeopleWhereWhereConditionsFriendsConditions!]
}
enum QueryPeopleWhereWhereConditionsFriendsConditions {
NAME
AGE
}|
Is this abandoned? Do we have a way to define the column names for relations? |
You can try @searchBy directive ;) |
Are there any chances of this being integrated into core? |
Maybe in the future, please see #1782 (comment) |
#1754
Changes
Allow constraining the allowed relations to an
enumvia the directive argumentsrelationsandrelationsEnumin@whereConditionsand@whereHasConditions. This works analogous tocolumnsandcolumnsEnum.Breaking changes
None.