jet
jet copied to clipboard
[Question] How to use JSONB types in where clauses
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?
Hi @masterkidan. Json expressions are currently not supported. You'll have to use raw expressions:
.WHERE(RawBool("info ->> 'version' > excluded.info->>'version'"))
@go-jet , is RawBool not available for postgres?
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()).