Using Postgres' array types and operators

76 views
Skip to first unread message

google...@sql-workbench.net

unread,
Jun 13, 2016, 11:07:41 AM6/13/16
to Querydsl
Hello,

is it possible to use Postgres' array types and operators in QueryDSL?

I'm looking for something to map the expression ARRAY[column_name]  and the array concatenation operator some_array||some_column to QueryDSL.

Specifically in the context of a common table expression:

with recursive category_tree as (
 
select id, parent_id, sort_order, name, array[0,id] as sort_path, 0 as level
 
from category
 
where parent_id is null
 
union all
 
select c.id, c.parent_id, c.sort_order, c.name, p.sort_path||array[c.sort_order, c.id], p.level + 1
 
from category c
    join category_tree p on c
.parent_id = p.id
)
select *
from category_tree
order
by sort_path;


How would I write a template (?) to support the array[0,id] and p.sort_path||array[c.sort_order, c.id] expressions?

I already have the rest, but I have no clue how to integrate something like that.

We have already written support for the array_agg() aggregate function, but this seems quite different.

timowest

unread,
Jun 15, 2016, 2:39:47 PM6/15/16
to Querydsl
Querydsl templates have fixed amounts of parameters, here are the variants for two parameters:
concat: {0} || {1}
array constructor: array[{0}, {1}]

google...@sql-workbench.net

unread,
Sep 7, 2016, 8:20:37 AM9/7/16
to Querydsl
How would I define such a template?

I don't really understand how the Java code for that would look like.
Reply all
Reply to author
Forward
0 new messages