sql-formatter
sql-formatter copied to clipboard
Please don't indent JOIN-s
JOIN clauses are at the same hierarchy level as FROM clause, which is correctly not indented.
F.e. better formatting for
...
FROM
{shop} AS s
LEFT JOIN {shop_price} AS pr ON pr.good_id = s.id
AND pr.trash = '0'
AND pr.date_start <= 1469606657
AND (
pr.date_start = 0
OR pr.date_finish >= 1469606657
)
AND pr.currency_id = 0
AND pr.role_id = 0
AND (pr.person = '0')
INNER JOIN {shop_param_element} AS pe3 ON pe3.element_id = s.id
AND pe3.param_id = '%d'
AND pe3.trash = '0'
...
.. would be
...
FROM
{shop} AS s
LEFT JOIN {shop_price} AS pr ON pr.good_id = s.id
AND pr.trash = '0'
AND pr.date_start <= 1469606657
AND (
pr.date_start = 0
OR pr.date_finish >= 1469606657
)
AND pr.currency_id = 0
AND pr.role_id = 0
AND (pr.person = '0')
INNER JOIN {shop_param_element} AS pe3 ON pe3.element_id = s.id
AND pe3.param_id = '%d'
AND pe3.trash = '0'
...
technically, this is not true. Joins are a subpart of the FROM clause in SQL.
The indentation of AND in ON clauses is not good though