Home » Java » java – jOOQ surrounds functions with quotes even if the setting is turned off-Exceptionshub

java – jOOQ surrounds functions with quotes even if the setting is turned off-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:

I’ve turned off adding quotes in the settings:

.withRenderQuotedNames(RenderQuotedNames.NEVER)

But when I check the SQL log I still find double quotes in the output. jOOQ adds it to function calls:

select connect_by_isleaf LEAF, ms.MODULNAME, ms.MODULNAMESPRUNG, 
       TOSCA.PA_BEZ."MODULTOSCA_MENUBEZ"(ms.MODULNAMESPRUNG, 
       TOSCA.PA_BASIS."SPRACHE_USER"()) MENUBEZ, app.BEZKURZ 
       from TOSCA.MODULSPRUNG ms 
       join TOSCA.MODULTOSCA mt1 on (ms.MODULNAME = mt1.MODULNAME and mt1.MODULART = 'M') 
       left outer join TOSCA.MODULTOSCA mt2 on mt2.MODULNAME = ms.MODULNAMESPRUNG 
       left outer join TOSCA.APPLIKATION app on app.APPL = mt2.APPL 
       start with ms.MODULNAME = 'X000' 
       connect by (prior ms.MODULNAMESPRUNG = ms.MODULNAME and prior ms.FUNKTION = 'springen') 
       order siblings by ms.SEQUENZ

And procedure calls:

begin ? := TOSCA.PA_SPRACH."MSGALERT_TEXT" (P_MODULNAME => 'ALLE', P_LAUFNR => 0); end;

Is this a bug? Or do I have to configure something else?

How to&Answers:

A related bug has been reported recently. Perhaps a 3.12 regression: https://github.com/jOOQ/jOOQ/issues/9813. We’re currently investigating this.

A workaround would be to implement an ExecuteListener and regex-replace all function identifiers \."(\w+)"\( by .$1(:

class WorkaroundFor9813 extends DefaultExecuteListener {
    static final Pattern P = Pattern.compile("\.\"(\w+)\"\(");
    @Override
    public void renderEnd(ExecuteContext ctx) {
        ctx.sql(P.matcher(ctx.sql()).replaceAll(".$1("));
    }
}

Of course, that’s a workaround and it could match things by accident that it shouldn’t…