vertical-blank / sql-formatter

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

need additional space in ALTER TABLE ADD #40

Closed vopalev closed 3 years ago

vopalev commented 3 years ago

We have: ALTER TABLE public.Orders ADD CONSTRAINT "fk_Orders_ref_Customers" FOREIGN KEY (customer_id) REFERENCES public.Customers (id)

After standart SqlFormatter.format(sqlScript, FormatConfig.builder().build()): ALTER TABLE public.Orders ADD CONSTRAINT "fk_Orders_ref_Customers" FOREIGN KEY (customer_id) REFERENCES public.Customers (id)

Between public.Orders and ADD elements only row delimiter, without any spaces. And after replace all \n or \r we get invalid script: ALTER TABLE public.OrdersADD CONSTRAINT

vertical-blank commented 3 years ago

Hi. The formatted string is a valid SQL. If you want to make formatted queries into single line, replace \n or \r by , instead of remove them.

vopalev commented 3 years ago

Wow :) That's right! But I chose a little other solution. Many thanks!