@@ -13,7 +13,7 @@ defmodule SQL do
13
13
@ doc false
14
14
@ behaviour SQL
15
15
import SQL
16
- def config , do: unquote ( opts )
16
+ def sql_config , do: unquote ( opts )
17
17
def token_to_sql ( token ) , do: token_to_sql ( token )
18
18
defoverridable token_to_sql: 1
19
19
end
@@ -99,8 +99,8 @@ defmodule SQL do
99
99
100
100
defimpl Inspect , for: SQL do
101
101
def inspect ( sql , _opts ) do
102
- if Kernel . function_exported? ( sql . module , :config , 0 ) do
103
- Enum . reduce ( 0 .. length ( sql . params ) , to_string ( sql ) , & String . replace ( & 2 , sql . module . config ( ) [ :adapter ] . token_to_string ( { :binding , [ ] , [ & 1 ] } ) , sql . module . config ( ) [ :adapter ] . token_to_string ( Enum . at ( sql . params , & 1 ) ) , global: false ) )
102
+ if Kernel . function_exported? ( sql . module , :sql_config , 0 ) do
103
+ Enum . reduce ( 0 .. length ( sql . params ) , :persistent_term . get ( sql . id ) , & String . replace ( & 2 , sql . module . config ( ) [ :adapter ] . token_to_string ( { :binding , [ ] , [ & 1 ] } ) , sql . module . config ( ) [ :adapter ] . token_to_string ( Enum . at ( sql . params , & 1 ) ) , global: false ) )
104
104
else
105
105
Enum . reduce ( 0 .. length ( sql . params ) , to_string ( sql ) , & String . replace ( & 2 , SQL.String . token_to_sql ( { :binding , [ ] , [ & 1 ] } ) , SQL.String . token_to_sql ( Enum . at ( sql . params , & 1 ) ) ) )
106
106
end
@@ -110,7 +110,7 @@ defmodule SQL do
110
110
defimpl String.Chars , for: SQL do
111
111
def to_string ( sql ) do
112
112
cond do
113
- Kernel . function_exported? ( sql . module , :config , 0 ) -> Enum . map ( sql . query , & sql . module . config ( ) [ :adapter ] . token_to_string ( & 1 ) )
113
+ Kernel . function_exported? ( sql . module , :sql_config , 0 ) -> Enum . map ( sql . query , & sql . module . config ( ) [ :adapter ] . token_to_string ( & 1 ) )
114
114
Kernel . function_exported? ( sql . module , :token_to_string , 2 ) -> Enum . map ( sql . query , & sql . module . token_to_string ( & 1 ) )
115
115
true -> Enum . map ( sql . query , & SQL.String . token_to_sql ( & 1 ) )
116
116
end
0 commit comments