Original SQL
and (
(
upper(
m.name
) like '%1111%' escape '\'
)
or
(
upper(
m.partnumber
) like '%1111%' escape '\'
)
)
Format
FormatConfig config = FormatConfig.builder().indent(" ").linesBetweenQueries(1).build();
SqlFormatter.of(DbType.postgresql).format(sql, config)
Result
like ' % 1111 % ' escape ' \ '
During the formatting process, the formatter treats the percent sign (%) as a modulo operator, rather than as part of the LIKE expression. Similarly, the back slash () is also treated as a regular character separated by spaces。