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 aggregate operations to be used on key paths that start with a unary relationship #3216
Conversation
unary relationship. The constraint is now that the key path must traverse a to-many relationship, but it is no longer required to be the first key in the path. This allows for the following queries that were formerly rejected: ANY company.employees.age > 30 company.employees.@avg.age > 30 SUBQUERY(company.employees, $e, $e.age > 30).@count > 0
I think this resolves #2955. |
It does! |
start = end + 1; | ||
} while (end != NSNotFound); | ||
|
||
return ColumnReference(prop, indexes); | ||
if (isAggregate && !keyPathContainsToManyRelationship) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these two conditions are essentially the same, so they could be merged into isAggregate != keyPathContainsToManyRelationship
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They need to generate different error messages so I don't think this helps?
LGTM 👍 |
@"Aggregate operations can only be used on key paths that include an array property"); | ||
} else if (!isAggregate && keyPathContainsToManyRelationship) { | ||
@throw RLMPredicateException(@"Invalid predicate", | ||
@"Aggregate operations must be used on key paths that include an array property"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be clearer to say "Key paths that include an array property must use aggregate operations". The current wording could reasonably be interpreted to mean the same thing as the error above, when it's actually the opposite case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, definitely clearer.
👍 |
…-link Allow aggregate operations to be used on key paths that start with a unary relationship
The constraint is now that the key path must traverse a to-many relationship, but it is no longer required to be the first key in the path.
This allows for the following queries that were formerly rejected:
Fixes #2955.