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

Support resources as aggregate targets in expressions #939

Open
vonagam opened this issue Mar 21, 2024 · 1 comment
Open

Support resources as aggregate targets in expressions #939

vonagam opened this issue Mar 21, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@vonagam
Copy link
Contributor

vonagam commented Mar 21, 2024

Right now aggregates (exists, max, count and so on) in expressions (expr) work only with relationships expr(exists(friends, name == "John")). It would be handy in some cases to have ability to specify aggregates using resources as targets - expr(exists(User, name == "John")).

Recent case where I've encountered it is about create policies as they do not have relationships setup yet. I can use simple check but expression one would have been shorter and cleaner.

I've seen hacks with declaring a has_many relationship with no_attributes?: true and then using that relationship as target for aggregates but would prefer for it to be supported officially so to speak.

@vonagam vonagam added enhancement New feature or request needs review labels Mar 21, 2024
@zachdaniel
Copy link
Contributor

I'm a fan of this proposal, but it will be a pretty significant change, as all aggregates are currently expecting to be at some relationship path to the resource. Its definitely doable, and should be doable without being a breaking change for users though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Someday
Development

No branches or pull requests

2 participants