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 aggregate operations to be used on key paths that start with a unary relationship #3216

Merged
merged 3 commits into from Feb 15, 2016

Conversation

bdash
Copy link
Contributor

@bdash bdash commented Feb 15, 2016

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

Fixes #2955.

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
@jpsim
Copy link
Contributor

jpsim commented Feb 15, 2016

I think this resolves #2955.

@bdash
Copy link
Contributor Author

bdash commented Feb 15, 2016

It does!

start = end + 1;
} while (end != NSNotFound);

return ColumnReference(prop, indexes);
if (isAggregate && !keyPathContainsToManyRelationship) {
Copy link
Contributor

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.

Copy link
Contributor Author

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?

@jpsim
Copy link
Contributor

jpsim commented Feb 15, 2016

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");
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, definitely clearer.

@tgoyne
Copy link
Member

tgoyne commented Feb 15, 2016

👍

bdash added a commit that referenced this pull request Feb 15, 2016
…-link

Allow aggregate operations to be used on key paths that start with a unary relationship
@bdash bdash merged commit c4f885d into master Feb 15, 2016
@bdash bdash removed the S:Review label Feb 15, 2016
@bdash bdash deleted the mar/aggregate-starting-from-unary-link branch February 15, 2016 23:48
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support ANY modifier with nested keypaths
3 participants