return ctx
.select(
sum(field("(short_deal_json -> 'contractInfo' ->> 'price')::NUMERIC", BigDecimal::class.java))
- sum(field("(short_deal_json ->> 'deposit')::NUMERIC", BigDecimal::class.java))
)
.from(DEAL)
.where(DEAL.STATE.eq(DealState.REGISTRATION))
.fetchOneInto(BigDecimal::class.java)
ctx
.select(DEAL.DEAL_NO)
.from(DEAL)
.where(normalizedField("buyer,person,firstName").eq(firstName))
.and(normalizedField("buyer,person,lastName").eq(lastName))
.and(
if (patronymic == null) {
DSL.field("request_json #>> '{buyer,person,patronymic}'").isNull
} else {
normalizedField("buyer,person,patronymic").eq(patronymic)
}
)
.and(DSL.field("request_json #>> '{contractInfo,cadastralNum}'", String::class.java).eq(cadastralNum))
.and(
if (contractNumber == null) {
DSL.field("request_json #>> '{contractInfo,contractNumber}'").isNull
} else {
normalizedContractField("contractInfo,contractNumber").eq(contractNumber)
}
)
.fetch(DEAL.DEAL_NO)
I think it would make sense to implement some type of sub-dsl for work with JSON values, like GSON's one: asJsonObjetc, asJsonArray and so on.
Regarding 3rd point of my tweet, JSON introspection. I think that it may be possible to convert JSON to Records, by using this project. Of course, generated source will need some corrections, according to Record semantics, but it will give developers ability to work with json fields almost like with related tables. Moreover, it will be possible to make updates to sub-entities and then update whole entity without performing ultra-complex queries!
One of the problems with these things is that they are very poorly standardised, and it will thus be rather difficult for jOOQ to standardise on such an API
there's always an ordinary function name backing the implementation of such operators, but they're not really idiomatic
It's definitely out of scope for jOOQ to integrate with such third party tools (and maintain the integration).
Hi Lukas,One of the problems with these things is that they are very poorly standardised, and it will thus be rather difficult for jOOQ to standardise on such an APIIf I understand problem correctly, JSONB is standartized not by SQL standart, but by Postgres itself. So it should be possible to create custom type (PostgresJson for example), which will have it's own custom functions.
It was quite predictable. I'm fully agree, that this is not high-priority feature, remembering that Postgres customers are not paid ones. It was just idea
--
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/BCcli15pbm0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jooq-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.