jdorn / sql-formatter

A lightweight php class for formatting sql statements. Handles automatic indentation and syntax highlighting.
http://jdorn.github.com/sql-formatter/
MIT License
3.89k stars 186 forks source link

A syntax error occurs in SQL formatting when sql code has '!=' operator #109

Open xingorg1 opened 2 years ago

xingorg1 commented 2 years ago

When sql code has "!= "operator, formatting code gets wrong syntax formatting"! = ". There is an extra space between the "!" symbol and the "=" symbol

for example:

SELECT
  *
FROM
  tableName
WHERE
  dt = '2021-11-09'
  AND some != '111'

i‘ll get it

SELECT
  *
FROM
  tableName
WHERE
  dt = '2021-11-09'
  AND some ! = '111'

Here's how I use it:

import { format as sqlFormatter } from "sql-formatter";

let newVal = "SELECT * FROM tableName WHERE dt='2021-06-09' AND some != '111'"
sqlFormatter(newVal);

sql-formatter@4.0.2 browser:Chrome@latest