agrestio / agrest

Server-side Java REST Framework for easy access to data graphs from various backends
https://agrest.io
Apache License 2.0
80 stars 34 forks source link

"(not) exists" expressions #647

Open andrus opened 11 months ago

andrus commented 11 months ago

Would be great to support (not) exists Agrest expressions to filter on the contents of to-many relationships. E.g.:

// at least one related object is present
?exp=exists details

// no related objects are present
?exp=not exists details

// no related objects matching the condition are present
?exp=not exists (details.value between 5 and 6)

// at least one related object is present matching the condition. 
// Condition includes both root and related properties
?exp=exists (details.value = value)

Cayenne will not support this until 5.0 per https://issues.apache.org/jira/browse/CAY-2816 . But we can still add this syntax to Agrest expression parser and Java DSL, and translate it to Cayenne subqueries.