vertical-blank/sql-formatter

Extra space inserted inside backtick strings

Closed this issue · 2 comments

If I format an SQL string like this:

SELECT * FROM `tableName`;

The resulting formatted string is like this:

SELECT * FROM ` tableName `;

The extra spaces break my query. Is there a way to fix this, or an option to disable this particular extra space?

@whiterook6
Treating backquotes as identifier literals is MySQLs dialect, so try this.

SqlFormatter
  .of(Dialect.MySql)
  .format("SELECT * FROM `tableName`;")

That seems to work! Thank you.