Skip to content

Commit 53d321a

Browse files
committed
poking around
1 parent 0d19210 commit 53d321a

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

lib/ecto/adapters/clickhouse.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ defmodule Ecto.Adapters.ClickHouse do
164164
def dumpers(:uuid, Ecto.UUID), do: [&__MODULE__.hex_uuid/1]
165165
def dumpers(:uuid, type), do: [type, &__MODULE__.hex_uuid/1]
166166
def dumpers(:binary_id, type), do: [type, &__MODULE__.hex_uuid/1]
167+
def dumpers({:in, sub}, {:in, sub}), do: [{:array, sub}]
167168
def dumpers(_primitive, {:parameterized, {Ch, params}}), do: [dumper(params)]
168169
def dumpers({:parameterized, {Ch, params}}, type), do: [type, dumper(params)]
169170
def dumpers(_primitive, type), do: [type]

lib/ecto/adapters/clickhouse/connection.ex

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,16 @@ defmodule Ecto.Adapters.ClickHouse.Connection do
678678

679679
defp expr({:in, _, [_, {:^, _, [_ix, 0]}]}, _sources, _params, _query), do: "0"
680680

681+
# Handle IN with pinned array parameter - use single array param instead of expanding
682+
defp expr({:in, _, [left, {:^, _, [ix, len]}]}, sources, params, query) when len > 0 do
683+
# Collect all the individual params into a single array
684+
array_values = Enum.map(ix..(ix + len - 1), &Enum.at(params, &1))
685+
p = build_param(ix, array_values)
686+
binding() |> dbg
687+
688+
[expr(left, sources, params, query), " IN ", p]
689+
end
690+
681691
defp expr({:in, _, [left, right]}, sources, params, query) do
682692
[expr(left, sources, params, query), " IN ", expr(right, sources, params, query)]
683693
end

test/ecto/integration/assoc_test.exs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ defmodule Ecto.Integration.AssocTest do
55
alias Ecto.Integration.{Post, Comment, Permalink}
66

77
test "has_many assoc" do
8+
Logger.configure(level: :debug)
89
p1 = TestRepo.insert!(%Post{title: "1"})
910
p2 = TestRepo.insert!(%Post{title: "2"})
1011

@@ -16,6 +17,8 @@ defmodule Ecto.Integration.AssocTest do
1617
assert c1.id == cid1
1718
assert c2.id == cid2
1819

20+
TestRepo.to_sql(:all, Ecto.assoc([p1, p2], :comments)) |> dbg
21+
1922
[c1, c2, c3] = TestRepo.all(Ecto.assoc([p1, p2], :comments)) |> Enum.sort_by(& &1.id)
2023
assert c1.id == cid1
2124
assert c2.id == cid2

0 commit comments

Comments
 (0)