HQL syntax sugar for array operations #7482
Replies: 2 comments 2 replies
-
To be clear I have not thought it through, but I was thinking of something like this:
I think it would be much nicer if this was handled by the existing |
Beta Was this translation helpful? Give feedback.
2 replies
-
I created https://hibernate.atlassian.net/browse/HHH-17375 for this work. Further comments/questions/suggestions can happen on the Jira issue. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Since we implemented array functions now as discussed via #7392, #7462 and #7480, we were thinking about making it easier for people to work with arrays.
One such simplification was by implementing syntax sugar for concatenating arrays with the
||
(double pipe) operator.@gavinking brought up some other possible simplifications. I'll list them here and we can discuss these simplifications:
[elem1, elem2, ...]
in
predicatearray[1]
array_
prefix i.e.length()
for arraysSome proposals which I don't think will fly are the following:
concat
. I don't think it's worth it, since we have support for the||
operator already. I think this would only complicate the rendering/construction in theconcat
function, but we can certainly try this.Here are additional some ideas I have for simplification:
overlaps
andcontains
predicates i.e.where e.array contains 'abc'
. These can be used for range type support and Hibernate Spatial as well.array_slice(array, 1, 10)
=>array[1:10]
Here is a list of the functions we have or plan to have:
array()
[elem1, elem2]
array_agg()
array_position()
position()
array_positions()
array_length()
length()
array_concat()
array_prepend()
array_append()
array_contains()
contains
predicatearray_contains_nullable()
array_overlaps()
overlaps
predicatearray_overlaps_nullable()
array_get()
array[1]
array_set()
array_remove()
array_remove_index()
array_slice()
array[1:10]
array_replace()
array_trim()
array_fill()
array_to_string()
Thoughts or concerns with the presented syntax sugar? Ideas about further syntax sugar? Let me know in the comments!
Beta Was this translation helpful? Give feedback.
All reactions