vertical-blank / sql-formatter

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

Extra space inserted inside backtick strings #54

Closed whiterook6 closed 2 years ago

whiterook6 commented 2 years ago

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?

vertical-blank commented 2 years ago

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

SqlFormatter
  .of(Dialect.MySql)
  .format("SELECT * FROM `tableName`;")
whiterook6 commented 2 years ago

That seems to work! Thank you.