1

Let's say I have a query of the type:

SELECT * FROM users WHERE access_codes @>
    ARRAY[(SELECT access_code FROM provisional_access)];

How would I write this in jooq? The best I have done so far is:

ctx.selectFrom(Tables.USERS).where(Tables.USERS.ACCESS_CODES).contains(
    ?? ctx.select(Tables.PROVISIONAL_ACCESS.ACCESS_CODE).from(Tables.PROVISIONAL_ACCESS) ??
);

1 Answer 1

1

This currently isn't supported by jOOQ out of the box, but you can very easily implement a utility function using "plain SQL":

public static <T> Condition arrayContains(
    Field<T[]> left, Select<? extends Record1<T>> right
) {
    return DSL.condition("{0} @> ARRAY[({1})]", left, right);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.