Skip to content
Draft
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
54 changes: 54 additions & 0 deletions test/ecto/integration/schema_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
defmodule Ecto.Integration.SchemaTest do
use Ecto.Integration.Case
import Ecto.Query, only: [from: 2]
alias Ecto.Integration.TestRepo

setup do
TestRepo.query!("""
create table schema_test (
id UInt64,
array_tuple_dynamic Array(Tuple(a LowCardinality(String), b LowCardinality(String), c LowCardinality(String), d Dynamic))
) ENGINE = MergeTree ORDER BY tuple()
""")

on_exit(fn -> TestRepo.query!("drop table schema_test") end)
end

defmodule Schema do
use Ecto.Schema

@primary_key false
schema "schema_test" do
field :id, Ch, type: "UInt64"

# TODO preserve names in named tuples
field :array_tuple_dynamic, {:array, Ch},
type:
"Tuple(LowCardinality(String), LowCardinality(String), LowCardinality(String), Dynamic)"
end
end

describe "insert_all/3" do
@tag :dynamic
test "with array of tuples containing dynamic type" do
TestRepo.insert_all(
Schema,
[
%{id: 1, array_tuple_dynamic: [{"a1", "b1", "c1", "d1"}]},
%{id: 2, array_tuple_dynamic: []}
],
# TODO remove this workaround when Ch preserves names in named tuples
settings: [input_format_with_types_use_header: 0]
)

assert TestRepo.all(
from s in Schema,
select: map(s, [:id, :array_tuple_dynamic]),
order_by: s.id
) == [
%{id: 1, array_tuple_dynamic: [{"a1", "b1", "c1", "d1"}]},
%{id: 2, array_tuple_dynamic: []}
]
end
end
end
4 changes: 2 additions & 2 deletions test/test_helper.exs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ exclude =
if ch_version >= "25" do
[]
else
# Time type is not supported in older ClickHouse versions we have in the CI
[:time]
# Time and Dynamic types are not supported in older ClickHouse versions we have in the CI
[:time, :dynamic]
end

ExUnit.start(exclude: exclude)
Loading