Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/ecto/adapters/myxql/connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -778,8 +778,8 @@ if Code.ensure_loaded?(MyXQL) do
[to_string(literal)]
end

defp expr({:splice, _, [{:^, _, [_, length]}]}, _sources, _query) do
Enum.intersperse(List.duplicate(??, length), ?,)
defp expr({:splice, _, splice_exprs}, sources, query) do
Enum.map_intersperse(splice_exprs, ",", &expr(&1, sources, query))
end

defp expr({:selected_as, _, [name]}, _sources, _query) do
Expand Down
4 changes: 2 additions & 2 deletions lib/ecto/adapters/postgres/connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -997,8 +997,8 @@ if Code.ensure_loaded?(Postgrex) do
[to_string(literal)]
end

defp expr({:splice, _, [{:^, _, [idx, length]}]}, _sources, _query) do
Enum.map_join(1..length, ",", &"$#{idx + &1}")
defp expr({:splice, _, splice_exprs}, sources, query) do
Enum.map_intersperse(splice_exprs, ",", &expr(&1, sources, query))
end

defp expr({:selected_as, _, [name]}, _sources, _query) do
Expand Down
4 changes: 2 additions & 2 deletions lib/ecto/adapters/tds/connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -838,8 +838,8 @@ if Code.ensure_loaded?(Tds) do
[to_string(literal)]
end

defp expr({:splice, _, [{:^, _, [idx, length]}]}, _sources, _query) do
list_param_to_args(idx, length)
defp expr({:splice, _, splice_exprs}, sources, query) do
Enum.map_intersperse(splice_exprs, ",", &expr(&1, sources, query))
end

defp expr({:selected_as, _, [name]}, _sources, _query) do
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ defmodule EctoSQL.MixProject do
if path = System.get_env("ECTO_PATH") do
{:ecto, path: path}
else
{:ecto, git: "https://github.com/elixir-ecto/ecto.git", branch: "master"}
{:ecto, git: "https://github.com/greg-rychlewski/ecto.git", branch: "dynamic_splice"}
end
end

Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"decimal": {:hex, :decimal, "2.3.0", "3ad6255aa77b4a3c4f818171b12d237500e63525c2fd056699967a3e7ea20f62", [:mix], [], "hexpm", "a4d66355cb29cb47c3cf30e71329e58361cfcb37c34235ef3bf1d7bf3773aeac"},
"deep_merge": {:hex, :deep_merge, "1.0.0", "b4aa1a0d1acac393bdf38b2291af38cb1d4a52806cf7a4906f718e1feb5ee961", [:mix], [], "hexpm", "ce708e5f094b9cd4e8f2be4f00d2f4250c4095be93f8cd6d018c753894885430"},
"earmark_parser": {:hex, :earmark_parser, "1.4.44", "f20830dd6b5c77afe2b063777ddbbff09f9759396500cdbe7523efd58d7a339c", [:mix], [], "hexpm", "4778ac752b4701a5599215f7030989c989ffdc4f6df457c5f36938cc2d2a2750"},
"ecto": {:git, "https://github.com/elixir-ecto/ecto.git", "3ab6a20b255fe2cee1fd9f6ae160c6fde772dce7", [branch: "master"]},
"ecto": {:git, "https://github.com/greg-rychlewski/ecto.git", "13dfff3120fb5fb40bbb690c2699dfa6c73872e5", [branch: "dynamic_splice"]},
"ex_doc": {:hex, :ex_doc, "0.39.1", "e19d356a1ba1e8f8cfc79ce1c3f83884b6abfcb79329d435d4bbb3e97ccc286e", [:mix], [{:earmark_parser, "~> 1.4.44", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "8abf0ed3e3ca87c0847dfc4168ceab5bedfe881692f1b7c45f4a11b232806865"},
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
"makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"},
Expand Down
7 changes: 7 additions & 0 deletions test/ecto/adapters/myxql_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,13 @@ defmodule Ecto.Adapters.MyXQLTest do

assert all(query) == ~s{SELECT s0.`x` FROM `schema` AS s0 WHERE (s0.`x` in (?,?,?,?,?))}

query =
Schema
|> select([_], fragment("concat_ws(?,?)", ".", splice(^["public", dynamic([r], r.x)])))
|> plan()

assert all(query) == ~s{SELECT concat_ws('.',?,s0.`x`) FROM `schema` AS s0}

value = 13
query = Schema |> select([r], fragment("lcase(?, ?)", r.x, ^value)) |> plan()
assert all(query) == ~s{SELECT lcase(s0.`x`, ?) FROM `schema` AS s0}
Expand Down
7 changes: 7 additions & 0 deletions test/ecto/adapters/postgres_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,13 @@ defmodule Ecto.Adapters.PostgresTest do

assert all(query) == ~s{SELECT s0."x" FROM "schema" AS s0 WHERE (s0."x" in ($1,$2,$3,$4,$5))}

query =
Schema
|> select([_], fragment("concat_ws(?,?)", ".", splice(^["public", dynamic([r], r.x)])))
|> plan()

assert all(query) == ~s{SELECT concat_ws('.',$1,s0."x") FROM "schema" AS s0}

value = 13
query = Schema |> select([r], fragment("downcase(?, ?)", r.x, ^value)) |> plan()
assert all(query) == ~s{SELECT downcase(s0."x", $1) FROM "schema" AS s0}
Expand Down
7 changes: 7 additions & 0 deletions test/ecto/adapters/tds_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,13 @@ defmodule Ecto.Adapters.TdsTest do

assert all(query) == ~s{SELECT s0.[x] FROM [schema] AS s0 WHERE (s0.[x] in (@1,@2,@3,@4,@5))}

query =
Schema
|> select([_], fragment("concat_ws(?,?)", ".", splice(^["public", dynamic([r], r.x)])))
|> plan()

assert all(query) == ~s{SELECT concat_ws(N'.',@1,s0.[x]) FROM [schema] AS s0}

value = 13
query = Schema |> select([r], fragment("lower(?)", ^value)) |> plan()
assert all(query) == ~s{SELECT lower(@1) FROM [schema] AS s0}
Expand Down
Loading