vertical-blank / sql-formatter

SQL formatter written with only Java Standard Library, without dependencies.
MIT License
227 stars 47 forks source link

jdbc named parameter support #53

Closed doukai closed 2 years ago

doukai commented 2 years ago

hi, in jdbc,the named parameter is :param but i find parameter in lib is @param any idea about replcase @ to : ? thanks~

vertical-blank commented 2 years ago

@doukai

Try this.

    Map<String, Object> params = new HashMap<>();
    params.put("param1", 1);

    String formatted =
        SqlFormatter.extend(cfg -> cfg.plusNamedPlaceholderTypes(":"))
            .format("SELECT * FROM table1 WHERE foo = :param1", params);
    System.out.println(formatted);
doukai commented 2 years ago

cool! very useful~