implementing overlap array function - postgres 9.5

74 views
Skip to first unread message

Leandro Aguilar

unread,
May 26, 2016, 11:24:18 AM5/26/16
to jOOQ User Group

Hi to all, how can I implement the following function with jooq 3.8.1 ?
tags column is an array of strings.

SELECT
  *
FROM
  public.objects
  where   tags && '{tag5,tag3}'::varchar[] ;


Lukas Eder

unread,
May 26, 2016, 12:44:09 PM5/26/16
to jooq...@googlegroups.com
Hi Leandro,

You can use jOOQ's "plain SQL" capabilities to create your own predicates:

In your case:

public static <T> void Condition arrayOverlaps(Field<T[]> left, Field<T[]> right) {
    return DSL.condition("{0} && {1}", left, right);
}

And call it as such:

arrayOverlaps(OBJECTS.TAGS, DSL.val(new String[] { "tag5", "tag3" }));

Hope this helps,
Lukas

--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

lehp...@gmail.com

unread,
Apr 20, 2017, 5:14:11 AM4/20/17
to jOOQ User Group
Hi,

Are there plans to add native support for this in jOOQ itself?
Sorry for bringing up an old thread.

Lukas Eder

unread,
Apr 20, 2017, 5:18:04 AM4/20/17
to jooq...@googlegroups.com
Interesting, that must've been an oversight in https://github.com/jOOQ/jOOQ/issues/3985, or the function wasn't available at the time yet.

I've added a feature request for this:

Will be an easy fix.

To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+unsubscribe@googlegroups.com.

Leandro Aparecido

unread,
Apr 20, 2017, 5:52:30 AM4/20/17
to jooq...@googlegroups.com
Great, thanks.

--
You received this message because you are subscribed to a topic in the Google Groups "jOOQ User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jooq-user/O2P-jEMVlYA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jooq-user+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages