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

[Question] How to use JSONB types in where clauses #167

Open
masterkidan opened this issue Jul 28, 2022 · 3 comments
Open

[Question] How to use JSONB types in where clauses #167

masterkidan opened this issue Jul 28, 2022 · 3 comments

Comments

@masterkidan
Copy link
Contributor

Hello,
Thanks for this great lib!. I happen to use a lot of JSONB types for postgres. One of the scenarios I have is to do a WHERE clause on a key value in a jsonb column, this would normally be something like this in postgres

insert into orders values(<valuelist>) on conflict(id) do update set (valuelist) where info ->> 'version' > excluded.info->>'version' 

Whats the JET way of representing the above statement?

@go-jet
Copy link
Owner

go-jet commented Jul 28, 2022

Hi @masterkidan.
Json expressions are currently not supported. You'll have to use raw expressions:

.WHERE(RawBool("info ->> 'version' > excluded.info->>'version'"))

@vamshiaruru-virgodesigns

@go-jet , is RawBool not available for postgres?

@go-jet
Copy link
Owner

go-jet commented Feb 20, 2023

Hmm, you're right RawBool is missing. Use BoolExp(Raw("info ->> 'version' > excluded.info->>'version'") instead. RawBool is just a short hand notation of BoolExp(Raw()).

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

No branches or pull requests

3 participants