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

Support newline and separator tokens in plain SQL templates #16630

Open
lukaseder opened this issue May 2, 2024 · 0 comments
Open

Support newline and separator tokens in plain SQL templates #16630

lukaseder opened this issue May 2, 2024 · 0 comments

Comments

@lukaseder
Copy link
Member

As a part of this task:

I just wrote this plain SQL template in jOOQ's internals:

s = DSL.resultQuery("{0} union all {1}",
        select(map(name.fieldNames, n -> inline((Object) null).as(n))).where(falseCondition()),
        query
    );

The template was necessary because we can't place the query (a ResultQuery typed object) into a Select.unionAll(...) clause. Unfortunately, the formatting is now off:

with
  "cte" as (
    select null "c"
    where false union all select 1 "one"
  )
select "cte"."c"
from "cte"

It should be:

with
  "cte" as (
    select null "c"
    where false
    union all
    select 1 "one"
  )
select "cte"."c"
from "cte"

The unformatted version is fine, though:

with "cte" as (select null "c" where false union all select 1 "one") select "cte"."c" from "cte"

It would be cool if plain SQL templates had special placeholders for the usual Context.formatSeparator() and Context.formatNewline() semantics.

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

No branches or pull requests

1 participant