JOOQ : want to convert DSL to inline

Viewed 36

I have a DSL like

DSL.case_().when(field.equal('5'), true).else_(false)

it is creating bind values..

and I don't want bind values.. (for some specific use cases.. bind values aren't working)

Using DSL.inline isn't solving this...

for the character-based field.

when "my field name" = ''1'' then false
  else true

How do I make it inline & it should be able to handle various field dataTypes?

1 Answers

From your comments, I take that you're wrapping the entire expression with DSL.inline(T) for some reason, but that's not how it works. It doesn't take arbitrary expressions and forces its contents to be inlined. It just takes a value and inlines that, see also the manual. So, in your case, it used your expression as a bind value (calling toString() on it).

What you want is to wrap each individual value with DSL.inline(), e.g.:

when(field.eq(inline("5")), inline(true)).else_(inline(false))

Alternatively, you can globally set StatementType.STATIC_STATEMENT to inline all bind values.

Related