Unable to set quote stye in JOOQ (RenderNameStyle.QUOTED)
I want JOOQ to display quoted column names. This is what I tried reading the docs and StackOverflow:
DSLContext sql = DSL.using( SQLDialect.SQL99,
new Settings()
.withRenderNameStyle(RenderNameStyle.QUOTED)
.withRenderFormatted(true)
.withRenderKeywordStyle(RenderKeywordStyle.UPPER)
);
System.out.println( "Quoted: " + (sql.settings().getRenderNameStyle()==RenderNameStyle.QUOTED) );
Table<Record> table = table("MyTable");
Field<Long> lid = field("id",Long.class);
String sqlStr = sql.renderInlined(
sql.select( lid, field("type"), field("request.id"), field("UPPERCASE"), field("lowercase") )
.from(table)
.limit(1000)
);
System.out.println(sqlStr);
Generated statement:
SELECT
id,
type,
request.id,
UPPERCASE,
lowercase
FROM MyTable
LIMIT 1000
It outputs Quoted: true
, so the flag seems to be set. Though renderFormatted
, and renderKeywordStyle
seems to have observed, `renderNameStyle`` ignored.
I am experimenting with an unsupported database, so SQL99. Side question: why is SQL99 deprecated in JOOQ?
source to share
DSL.field(String)
methods are used to embed "plain SQL" in jOOQ. jOOQ does not parse your SQL strings and therefore does not know what parts you think of as "names" such as type
or request
and id
.
If you don't want to use a code generator, you must use DSL.field(Name)
to create fields whose names are affected RenderNameStyle
. Name
can be created withDSL.name(String...)
I am experimenting with an unsupported database, so SQL99. Side question: why is SQL99 deprecated in JOOQ?
Because the name is misleading. jOOQ doesn't actually generate SQL99 as there are no integration tests to prove that the output is indeed correct or meaningful according to the standard. In a future release, jOOQ SQL99
will be replaced with a dialect DEFAULT
that probably won't work in any database.
source to share