Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Field::contains should implement PostgreSQL @> also for JSONB types #14262

Closed
saibotma opened this issue Nov 21, 2022 · 8 comments
Closed

Field::contains should implement PostgreSQL @> also for JSONB types #14262

saibotma opened this issue Nov 21, 2022 · 8 comments

Comments

@saibotma
Copy link

Use case

@> can be GIN-Indexed and thus useful to quickly lookup if a key-value pair exists.

Possible solution

No response

Possible workarounds

No response

jOOQ Version

jOOQ Community 3.17.5

Database product and version

Postgres 15 and older

Java Version

No response

OS Version

No response

JDBC driver name and version (include name if unofficial driver)

No response

@lukaseder
Copy link
Member

Thanks for your report. We already support it via Field.contains(), though only for arrays. Did you have something else in mind?

@saibotma
Copy link
Author

saibotma commented Nov 21, 2022

I also noticed that Field.contains() exists. Should've checked more carefully before creating an issue 😅
I want to use it with JSON/JSONB as shown here.

Using it on Field<JSONB> compiles at least. I did not execute the query yet, though.

@lukaseder lukaseder changed the title Add support for Postgres @> operator Field::contains should implement PostgreSQL @> also for JSON and JSONB types Nov 21, 2022
@lukaseder
Copy link
Member

Makes sense, thanks. Yes it compiles but generates a string contains implementation, i.e. arg1 like '%' || arg2 || '%'. It certainly makes sense to retrofit this for JSON and JSONB

@saibotma
Copy link
Author

Thanks for the information. That means the current workaround is to use jOOQ's plain SQL support?

@lukaseder
Copy link
Member

Yes

@lukaseder lukaseder changed the title Field::contains should implement PostgreSQL @> also for JSON and JSONB types Field::contains should implement PostgreSQL @> also for JSONB types Nov 21, 2022
@lukaseder
Copy link
Member

Will implement native support only for now. Emulations could be done separately: #14264, though they're probably not so simple.

lukaseder added a commit that referenced this issue Nov 21, 2022
…B types

This includes:

[#14263] Add jsonbObject() convenience overloads for single element objects
@lukaseder
Copy link
Member

Fixed for jOOQ 3.18.0

3.18 Other improvements automation moved this from To do to Done Nov 21, 2022
@saibotma
Copy link
Author

Wow, that was fast!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

2 participants