Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow constraining allowed relations in @whereConditions and @whereHasConditions #1896

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

spawnia
Copy link
Collaborator

@spawnia spawnia commented Jul 18, 2021

  • Added or updated tests
  • Documented user facing changes
  • Updated CHANGELOG.md

#1754

Changes

Allow constraining the allowed relations to an enum via the directive arguments relations and relationsEnum in @whereConditions and @whereHasConditions. This works analogous to columns and columnsEnum.

Breaking changes

None.

@spawnia spawnia changed the title Allow constraining allowed relations in @whereConditions Allow constraining allowed relations in @whereConditions and @whereHasConditions Dec 30, 2021
@spawnia
Copy link
Collaborator Author

spawnia commented Dec 30, 2021

@LastDragon-ru please review.

@spawnia spawnia added the enhancement A feature or improvement label Dec 30, 2021
Copy link
Contributor

@LastDragon-ru LastDragon-ru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for delay. Looks good I think 👍

docs/5/eloquent/complex-where-conditions.md Outdated Show resolved Hide resolved
@@ -129,10 +155,18 @@ input QueryPeopleWhereWhereConditionsRelation {
"Additional condition logic."
condition: QueryPeopleWhereWhereConditions
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
}

@esistgut
Copy link

Is this abandoned? Do we have a way to define the column names for relations?

@LastDragon-ru
Copy link
Contributor

Do we have a way to define the column names for relations?

You can try @searchBy directive ;)

@esistgut
Copy link

You can try @searchBy directive ;)

Are there any chances of this being integrated into core?

@LastDragon-ru
Copy link
Contributor

Are there any chances of this being integrated into core?

Maybe in the future, please see #1782 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A feature or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants