@@ -19,8 +19,10 @@ defmodule SQL.Format do
1919
2020 defp indention ( acc , [ { _ , { _ , _ , _ , _ , _ , 0 } } | _ ] , _ ) , do: acc
2121 defp indention ( acc , [ { _ , { _ , _ , _ , _ , _ , 0 , _ , _ } } | _ ] , _ ) , do: acc
22+ defp indention ( acc , [ { _ , { _ , _ , _ , _ , _ , _ } } | _ ] , 0 ) , do: [ ?\s | acc ]
23+ defp indention ( acc , [ { _ , { _ , _ , _ , _ , _ , _ , _ , _ } } | _ ] , 0 ) , do: [ ?\s | acc ]
2224 defp indention ( acc , 0 , 0 ) , do: acc
23- defp indention ( acc , _ , 0 ) , do: [ ?\s | acc ]
25+ defp indention ( acc , _ , 0 ) , do: acc
2426 defp indention ( acc , _ , 1 ) , do: [ ?\s , ?\s | acc ]
2527 defp indention ( acc , m , indent ) , do: indention ( [ ?\s , ?\s | acc ] , m , indent - 1 )
2628
@@ -41,10 +43,10 @@ defmodule SQL.Format do
4143 end
4244 for atom <- newline do
4345 defp to_iodata ( { unquote ( atom ) , _m , values } , binding , :lower = case , errors , indent , acc ) do
44- newline ( [ @ keyword , unquote ( "#{ atom } " ) , @ reset | newline ( to_iodata ( values , binding , case , errors , indent , acc ) , indent ) ] , indent )
46+ newline ( [ @ keyword , unquote ( "#{ atom } " ) , @ reset | pad ( to_iodata ( values , binding , case , errors , indent + 1 , acc ) ) ] , indent )
4547 end
4648 defp to_iodata ( { unquote ( atom ) , _m , values } , binding , :upper = case , errors , indent , acc ) do
47- newline ( [ @ keyword , unquote ( String . upcase ( "#{ atom } " ) ) , @ reset | newline ( to_iodata ( values , binding , case , errors , indent , acc ) , indent ) ] , indent )
49+ newline ( [ @ keyword , unquote ( String . upcase ( "#{ atom } " ) ) , @ reset | pad ( to_iodata ( values , binding , case , errors , indent + 1 , acc ) ) ] , indent )
4850 end
4951 end
5052 for atom <- ~w[ group order] a do
@@ -61,8 +63,8 @@ defmodule SQL.Format do
6163 defp to_iodata ( :comma , _binding , _case , _errors , 0 , acc ) do
6264 [ ?, | acc ]
6365 end
64- defp to_iodata ( :comma , _binding , _case , _errors , indent , acc ) do
65- [ ?, | newline ( acc , indent ) ]
66+ defp to_iodata ( :comma , _binding , _case , _errors , _indent , acc ) do
67+ [ ?, | pad ( acc ) ]
6668 end
6769 defp to_iodata ( :dot , _binding , _case , _errors , _indent , acc ) do
6870 [ ?. | acc ]
0 commit comments