Skip to content

Commit b0ccc5f

Browse files
committed
namespace config function
1 parent 785b9fd commit b0ccc5f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/sql.ex

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ defmodule SQL do
1313
@doc false
1414
@behaviour SQL
1515
import SQL
16-
def config, do: unquote(opts)
16+
def sql_config, do: unquote(opts)
1717
def token_to_sql(token), do: token_to_sql(token)
1818
defoverridable token_to_sql: 1
1919
end
@@ -99,8 +99,8 @@ defmodule SQL do
9999

100100
defimpl Inspect, for: SQL do
101101
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))
104104
else
105105
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))))
106106
end
@@ -110,7 +110,7 @@ defmodule SQL do
110110
defimpl String.Chars, for: SQL do
111111
def to_string(sql) do
112112
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))
114114
Kernel.function_exported?(sql.module, :token_to_string, 2) -> Enum.map(sql.query, &sql.module.token_to_string(&1))
115115
true -> Enum.map(sql.query, &SQL.String.token_to_sql(&1))
116116
end

0 commit comments

Comments
 (0)