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

Expression parser to support "|" path separator #656

Closed andrus closed 10 months ago

andrus commented 10 months ago

The expression grammar should support | as a relationship path separator and also as a path prefix (e.g. |a.b, a|b). This would indicate a "split", serving as a hint to the processor that unique "joins" or "aliases" need to be generated for each repeating segment following the split. E.g.:

// "either 5 or 6" (without split)
a.b = 5 or a.b = 6

// "both 5 and 6" (with a split)
a|b = 5 and a|b = 6

What makes things more tricky is that a|b is currently interpreted as a bitwise or. Also this syntax makes the most sense when used in the API (matchAll("a|b", list)), not in a String expression where the number of operands in fixed. Perhaps we should pursue the alias syntax instead (the pipe is a special case of aliases) per #657