vertical-blank / sql-formatter

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

new format config for skipping white spaces before and after block pa… #69

Closed hemlac closed 5 months ago

hemlac commented 8 months ago

With this new config parameter you are able to skip white spaces before and after block parentheses. For example Without this parameter: CREATE VIEW sakila.v_exampl (customer, phone, title) AS select concat(sakila.customer.last_name,', ',sakila.customer.first_name) AS customer,sakila.address.phone AS phone,sakila.film.title AS title from ((((sakila.rental join sakila.customer on((sakila.rental.customer_id = sakila.customer.customer_id))) join sakila.address on((sakila.customer.address_id = sakila.address.address_id))) join sakila.inventory on((sakila.rental.inventory_id = sakila.inventory.inventory_id))) join sakila.film on((sakila.inventory.film_id = sakila.film.film_id))) where ((sakila.rental.return_date is null) and ((sakila.rental.rental_date + interval sakila.film.rental_duration day) < curdate())) order by sakila.film.title limit 5 Result: CREATE VIEW sakila.v_exampl (customer, phone, title) AS select concat( sakila.customer.last_name, ', ', sakila.customer.first_name ) AS customer, sakila.address.phone AS phone, sakila.film.title AS title from ( ( ( ( sakila.rental join sakila.customer on( ( sakila.rental.customer_id = sakila.customer.customer_id ) ) ) join sakila.address on( ( sakila.customer.address_id = sakila.address.address_id ) ) ) join sakila.inventory on( ( sakila.rental.inventory_id = sakila.inventory.inventory_id ) ) ) join sakila.film on((sakila.inventory.film_id = sakila.film.film_id)) ) where ( (sakila.rental.return_date is null) and ( ( sakila.rental.rental_date + interval sakila.film.rental_duration day ) < curdate() ) ) order by sakila.film.title limit 5

With this new parameter CREATE VIEW sakila.v_exampl (customer, phone, title) AS select concat(sakila.customer.last_name, ', ', sakila.customer.first_name)AS customer, sakila.address.phone AS phone, sakila.film.title AS title from ((((sakila.rental join sakila.customer on((sakila.rental.customer_id = sakila.customer.customer_id))) join sakila.address on((sakila.customer.address_id = sakila.address.address_id))) join sakila.inventory on((sakila.rental.inventory_id = sakila.inventory.inventory_id))) join sakila.film on((sakila.inventory.film_id = sakila.film.film_id))) where ((sakila.rental.return_date is null) and ((sakila.rental.rental_date + interval sakila.film.rental_duration day)< curdate())) order by sakila.film.title limit 5

hemlac commented 5 months ago

@vertical-blank could you please review my pull request?

vertical-blank commented 5 months ago

@hemlac I am very sorry that I have kept you waiting for so long.

The Github actions were broken and I have fixed it. Could you please reopen the pull request to check the CI results?

hemlac commented 5 months ago

@vertical-blank done

vertical-blank commented 5 months ago

LGTM @hemlac Thanks a lot.

hemlac commented 5 months ago

@vertical-blank thank you too! can you please create a new release?

vertical-blank commented 5 months ago

@hemlac I've just released 2.0.5 to Maven Central. https://repo1.maven.org/maven2/com/github/vertical-blank/sql-formatter/2.0.5/

hemlac commented 5 months ago

@vertical-blank Thank you very much!