From eb8d62d1b4581a80965a796c864b59911a1c11a4 Mon Sep 17 00:00:00 2001 From: ruslandoga <67764432+ruslandoga@users.noreply.github.com> Date: Thu, 15 Aug 2024 10:53:43 +0700 Subject: [PATCH] update to ecto 3.12 --- lib/ch.ex | 2 +- mix.exs | 2 +- mix.lock | 6 ++-- test/ch/ecto_type_test.exs | 67 ++++++++++++++++++++------------------ 4 files changed, 40 insertions(+), 37 deletions(-) diff --git a/lib/ch.ex b/lib/ch.ex index 0a2b557..ad4217f 100644 --- a/lib/ch.ex +++ b/lib/ch.ex @@ -118,7 +118,7 @@ defmodule Ch do @behaviour Ecto.ParameterizedType @impl true - def type(params), do: {:parameterized, Ch, params} + def type(params), do: {:parameterized, {Ch, params}} @impl true def init(opts) do diff --git a/mix.exs b/mix.exs index 0e98d40..ec9f334 100644 --- a/mix.exs +++ b/mix.exs @@ -37,7 +37,7 @@ defmodule Ch.MixProject do {:db_connection, "~> 2.0"}, {:jason, "~> 1.0"}, {:decimal, "~> 2.0"}, - {:ecto, "~> 3.5", optional: true}, + {:ecto, "~> 3.12", optional: true}, {:benchee, "~> 1.0", only: [:bench]}, {:dialyxir, "~> 1.0", only: [:dev], runtime: false}, {:ex_doc, ">= 0.0.0", only: :docs}, diff --git a/mix.lock b/mix.lock index 9a5b89d..7d8e4de 100644 --- a/mix.lock +++ b/mix.lock @@ -4,15 +4,15 @@ "decimal": {:hex, :decimal, "2.1.1", "5611dca5d4b2c3dd497dec8f68751f1f1a54755e8ed2a966c2633cf885973ad6", [:mix], [], "hexpm", "53cfe5f497ed0e7771ae1a475575603d77425099ba5faef9394932b35020ffcc"}, "deep_merge": {:hex, :deep_merge, "1.0.0", "b4aa1a0d1acac393bdf38b2291af38cb1d4a52806cf7a4906f718e1feb5ee961", [:mix], [], "hexpm", "ce708e5f094b9cd4e8f2be4f00d2f4250c4095be93f8cd6d018c753894885430"}, "dialyxir": {:hex, :dialyxir, "1.4.3", "edd0124f358f0b9e95bfe53a9fcf806d615d8f838e2202a9f430d59566b6b53b", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "bf2cfb75cd5c5006bec30141b131663299c661a864ec7fbbc72dfa557487a986"}, - "earmark_parser": {:hex, :earmark_parser, "1.4.40", "f3534689f6b58f48aa3a9ac850d4f05832654fe257bf0549c08cc290035f70d5", [:mix], [], "hexpm", "cdb34f35892a45325bad21735fadb88033bcb7c4c296a999bde769783f53e46a"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.41", "ab34711c9dc6212dda44fcd20ecb87ac3f3fce6f0ca2f28d4a00e4154f8cd599", [:mix], [], "hexpm", "a81a04c7e34b6617c2792e291b5a2e57ab316365c2644ddc553bb9ed863ebefa"}, "ecto": {:hex, :ecto, "3.12.1", "626765f7066589de6fa09e0876a253ff60c3d00870dd3a1cd696e2ba67bfceea", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "df0045ab9d87be947228e05a8d153f3e06e0d05ab10c3b3cc557d2f7243d1940"}, - "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, + "erlex": {:hex, :erlex, "0.2.7", "810e8725f96ab74d17aac676e748627a07bc87eb950d2b83acd29dc047a30595", [:mix], [], "hexpm", "3ed95f79d1a844c3f6bf0cea61e0d5612a42ce56da9c03f01df538685365efb0"}, "ex_doc": {:hex, :ex_doc, "0.34.2", "13eedf3844ccdce25cfd837b99bea9ad92c4e511233199440488d217c92571e8", [:mix], [{:earmark_parser, "~> 1.4.39", [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", "5ce5f16b41208a50106afed3de6a2ed34f4acfd65715b82a0b84b49d995f95c1"}, "hpax": {:hex, :hpax, "1.0.0", "28dcf54509fe2152a3d040e4e3df5b265dcb6cb532029ecbacf4ce52caea3fd2", [:mix], [], "hexpm", "7f1314731d711e2ca5fdc7fd361296593fc2542570b3105595bb0bc6d0fad601"}, "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.1.2", "9ba8837913bdf757787e71c1581c21f9d2455f4dd04cfca785c70bbfff1a76a3", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cce1566b81fbcbd21eca8ffe808f33b221f9eee2cbc7a1706fc3da9ff18e6cac"}, "makeup_elixir": {:hex, :makeup_elixir, "0.16.2", "627e84b8e8bf22e60a2579dad15067c755531fea049ae26ef1020cad58fe9578", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "41193978704763f6bbe6cc2758b84909e62984c7752b3784bd3c218bb341706b"}, - "makeup_erlang": {:hex, :makeup_erlang, "1.0.0", "6f0eff9c9c489f26b69b61440bf1b238d95badae49adac77973cbacae87e3c2e", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "ea7a9307de9d1548d2a72d299058d1fd2339e3d398560a0e46c27dab4891e4d2"}, + "makeup_erlang": {:hex, :makeup_erlang, "1.0.1", "c7f58c120b2b5aa5fd80d540a89fdf866ed42f1f3994e4fe189abebeab610839", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "8a89a1eeccc2d798d6ea15496a6e4870b75e014d1af514b1b71fa33134f57814"}, "mint": {:hex, :mint, "1.6.2", "af6d97a4051eee4f05b5500671d47c3a67dac7386045d87a904126fd4bbcea2e", [:mix], [{:castore, "~> 0.1.0 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:hpax, "~> 0.1.1 or ~> 0.2.0 or ~> 1.0", [hex: :hpax, repo: "hexpm", optional: false]}], "hexpm", "5ee441dffc1892f1ae59127f74afe8fd82fda6587794278d924e4d90ea3d63f9"}, "nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"}, "statistex": {:hex, :statistex, "1.0.0", "f3dc93f3c0c6c92e5f291704cf62b99b553253d7969e9a5fa713e5481cd858a5", [:mix], [], "hexpm", "ff9d8bee7035028ab4742ff52fc80a2aa35cece833cf5319009b52f1b5a86c27"}, diff --git a/test/ch/ecto_type_test.exs b/test/ch/ecto_type_test.exs index 0c14533..be0754a 100644 --- a/test/ch/ecto_type_test.exs +++ b/test/ch/ecto_type_test.exs @@ -7,16 +7,18 @@ defmodule Ch.EctoTypeTest do end test "with :type" do - assert {:parameterized, Ch, :string} = Ecto.ParameterizedType.init(Ch, type: "String") + assert {:parameterized, {Ch, :string}} = Ecto.ParameterizedType.init(Ch, type: "String") end test "with :raw" do - assert {:parameterized, Ch, :string} = Ecto.ParameterizedType.init(Ch, raw: "String") + assert {:parameterized, {Ch, :string}} = Ecto.ParameterizedType.init(Ch, raw: "String") end end test "String" do - assert {:parameterized, Ch, :string} = type = Ecto.ParameterizedType.init(Ch, type: "String") + assert {:parameterized, {Ch, :string}} = + type = Ecto.ParameterizedType.init(Ch, type: "String") + assert Ecto.Type.type(type) == type assert Ecto.Type.format(type) == "#Ch" @@ -32,7 +34,7 @@ defmodule Ch.EctoTypeTest do end test "Nullable(String)" do - assert {:parameterized, Ch, {:nullable, :string}} = + assert {:parameterized, {Ch, {:nullable, :string}}} = type = Ecto.ParameterizedType.init(Ch, type: "Nullable(String)") assert Ecto.Type.type(type) == type @@ -50,7 +52,7 @@ defmodule Ch.EctoTypeTest do end test "LowCardinality(String)" do - assert {:parameterized, Ch, {:low_cardinality, :string}} = + assert {:parameterized, {Ch, {:low_cardinality, :string}}} = type = Ecto.ParameterizedType.init(Ch, type: "LowCardinality(String)") assert Ecto.Type.type(type) == type @@ -68,7 +70,7 @@ defmodule Ch.EctoTypeTest do end test "Array(String)" do - assert {:parameterized, Ch, {:array, :string}} = + assert {:parameterized, {Ch, {:array, :string}}} = type = Ecto.ParameterizedType.init(Ch, type: "Array(String)") assert Ecto.Type.type(type) == type @@ -88,7 +90,7 @@ defmodule Ch.EctoTypeTest do end test "{:array, String}" do - assert {:array, {:parameterized, Ch, :string}} = + assert {:array, {:parameterized, {Ch, :string}}} = type = {:array, Ecto.ParameterizedType.init(Ch, type: "String")} assert Ecto.Type.type(type) == type @@ -108,7 +110,7 @@ defmodule Ch.EctoTypeTest do end test "Tuple(String, Int64)" do - assert {:parameterized, Ch, {:tuple, [:string, :i64]}} = + assert {:parameterized, {Ch, {:tuple, [:string, :i64]}}} = type = Ecto.ParameterizedType.init(Ch, type: "Tuple(String, Int64)") assert Ecto.Type.type(type) == type @@ -129,7 +131,7 @@ defmodule Ch.EctoTypeTest do for size <- [8, 16, 32, 64, 128, 256] do for {encoded, decoded} <- [{"Int#{size}", :"i#{size}"}, {"UInt#{size}", :"u#{size}"}] do test encoded do - assert {:parameterized, Ch, unquote(decoded)} = + assert {:parameterized, {Ch, unquote(decoded)}} = type = Ecto.ParameterizedType.init(Ch, type: unquote(encoded)) assert Ecto.Type.type(type) == type @@ -147,7 +149,7 @@ defmodule Ch.EctoTypeTest do end test "Map(String, UInt64)" do - assert {:parameterized, Ch, {:map, :string, :u64}} = + assert {:parameterized, {Ch, {:map, :string, :u64}}} = type = Ecto.ParameterizedType.init(Ch, type: "Map(String, UInt64)") assert Ecto.Type.type(type) == type @@ -162,7 +164,7 @@ defmodule Ch.EctoTypeTest do for size <- [32, 64] do test "Float#{size}" do - assert {:parameterized, Ch, unquote(:"f#{size}")} = + assert {:parameterized, {Ch, unquote(:"f#{size}")}} = type = Ecto.ParameterizedType.init(Ch, type: unquote("Float#{size}")) assert Ecto.Type.type(type) == type @@ -181,7 +183,7 @@ defmodule Ch.EctoTypeTest do end test "Date" do - assert {:parameterized, Ch, :date} = type = Ecto.ParameterizedType.init(Ch, type: "Date") + assert {:parameterized, {Ch, :date}} = type = Ecto.ParameterizedType.init(Ch, type: "Date") assert Ecto.Type.type(type) == type assert Ecto.Type.format(type) == "#Ch" @@ -197,7 +199,8 @@ defmodule Ch.EctoTypeTest do end test "Date32" do - assert {:parameterized, Ch, :date32} = type = Ecto.ParameterizedType.init(Ch, type: "Date32") + assert {:parameterized, {Ch, :date32}} = + type = Ecto.ParameterizedType.init(Ch, type: "Date32") assert Ecto.Type.type(type) == type assert Ecto.Type.format(type) == "#Ch" @@ -213,7 +216,7 @@ defmodule Ch.EctoTypeTest do end test "Bool" do - assert {:parameterized, Ch, :boolean} = type = Ecto.ParameterizedType.init(Ch, type: "Bool") + assert {:parameterized, {Ch, :boolean}} = type = Ecto.ParameterizedType.init(Ch, type: "Bool") assert Ecto.Type.type(type) == type assert Ecto.Type.format(type) == "#Ch" @@ -229,7 +232,7 @@ defmodule Ch.EctoTypeTest do end test "DateTime" do - assert {:parameterized, Ch, :datetime} = + assert {:parameterized, {Ch, :datetime}} = type = Ecto.ParameterizedType.init(Ch, type: "DateTime") assert Ecto.Type.type(type) == type @@ -246,7 +249,7 @@ defmodule Ch.EctoTypeTest do end test "DateTime('UTC')" do - assert {:parameterized, Ch, {:datetime, "UTC"}} = + assert {:parameterized, {Ch, {:datetime, "UTC"}}} = type = Ecto.ParameterizedType.init(Ch, type: "DateTime('UTC')") assert Ecto.Type.type(type) == type @@ -264,7 +267,7 @@ defmodule Ch.EctoTypeTest do # TODO truncate? test "DateTime64(3)" do - assert {:parameterized, Ch, {:datetime64, 3}} = + assert {:parameterized, {Ch, {:datetime64, 3}}} = type = Ecto.ParameterizedType.init(Ch, type: "DateTime64(3)") assert Ecto.Type.type(type) == type @@ -289,7 +292,7 @@ defmodule Ch.EctoTypeTest do # TODO truncate? test "DateTime64(3, 'UTC')" do - assert {:parameterized, Ch, {:datetime64, 3, "UTC"}} = + assert {:parameterized, {Ch, {:datetime64, 3, "UTC"}}} = type = Ecto.ParameterizedType.init(Ch, type: "DateTime64(3, 'UTC')") assert Ecto.Type.type(type) == type @@ -313,7 +316,7 @@ defmodule Ch.EctoTypeTest do end test "SimpleAggregateFunction(any, String)" do - assert {:parameterized, Ch, {:simple_aggregate_function, "any", :string}} = + assert {:parameterized, {Ch, {:simple_aggregate_function, "any", :string}}} = type = Ecto.ParameterizedType.init(Ch, type: "SimpleAggregateFunction(any, String)") assert Ecto.Type.type(type) == type @@ -331,8 +334,8 @@ defmodule Ch.EctoTypeTest do end test "SimpleAggregateFunction(groupArrayArray, Array(DateTime('UTC')))" do - assert {:parameterized, Ch, - {:simple_aggregate_function, "groupArrayArray", {:array, {:datetime, "UTC"}}}} = + assert {:parameterized, + {Ch, {:simple_aggregate_function, "groupArrayArray", {:array, {:datetime, "UTC"}}}}} = type = Ecto.ParameterizedType.init(Ch, type: "SimpleAggregateFunction(groupArrayArray, Array(DateTime('UTC')))" @@ -359,7 +362,7 @@ defmodule Ch.EctoTypeTest do # TODO check size? test "FixedString(3)" do - assert {:parameterized, Ch, {:fixed_string, 3}} = + assert {:parameterized, {Ch, {:fixed_string, 3}}} = type = Ecto.ParameterizedType.init(Ch, type: "FixedString(3)") assert Ecto.Type.type(type) == type @@ -383,7 +386,7 @@ defmodule Ch.EctoTypeTest do full_encoded = encoded <> "('hello' = 1, 'world' = 2)" test full_encoded do - assert {:parameterized, Ch, {unquote(decoded), [{"hello", 1}, {"world", 2}]}} = + assert {:parameterized, {Ch, {unquote(decoded), [{"hello", 1}, {"world", 2}]}}} = type = Ecto.ParameterizedType.init(Ch, type: unquote(full_encoded)) assert Ecto.Type.type(type) == type @@ -412,7 +415,7 @@ defmodule Ch.EctoTypeTest do end test "UUID" do - assert {:parameterized, Ch, :uuid} = type = Ecto.ParameterizedType.init(Ch, type: "UUID") + assert {:parameterized, {Ch, :uuid}} = type = Ecto.ParameterizedType.init(Ch, type: "UUID") assert Ecto.Type.type(type) == type assert Ecto.Type.format(type) == "#Ch" @@ -429,7 +432,7 @@ defmodule Ch.EctoTypeTest do end test "IPv4" do - assert {:parameterized, Ch, :ipv4} = type = Ecto.ParameterizedType.init(Ch, type: "IPv4") + assert {:parameterized, {Ch, :ipv4}} = type = Ecto.ParameterizedType.init(Ch, type: "IPv4") assert Ecto.Type.type(type) == type assert Ecto.Type.format(type) == "#Ch" @@ -448,7 +451,7 @@ defmodule Ch.EctoTypeTest do end test "IPv6" do - assert {:parameterized, Ch, :ipv6} = type = Ecto.ParameterizedType.init(Ch, type: "IPv6") + assert {:parameterized, {Ch, :ipv6}} = type = Ecto.ParameterizedType.init(Ch, type: "IPv6") assert Ecto.Type.type(type) == type assert Ecto.Type.format(type) == "#Ch" @@ -470,7 +473,7 @@ defmodule Ch.EctoTypeTest do end test "Point" do - assert {:parameterized, Ch, :point} = type = Ecto.ParameterizedType.init(Ch, type: "Point") + assert {:parameterized, {Ch, :point}} = type = Ecto.ParameterizedType.init(Ch, type: "Point") assert Ecto.Type.type(type) == type assert Ecto.Type.format(type) == "#Ch" @@ -488,7 +491,7 @@ defmodule Ch.EctoTypeTest do end test "Ring" do - assert {:parameterized, Ch, :ring} = type = Ecto.ParameterizedType.init(Ch, type: "Ring") + assert {:parameterized, {Ch, :ring}} = type = Ecto.ParameterizedType.init(Ch, type: "Ring") assert Ecto.Type.type(type) == type assert Ecto.Type.format(type) == "#Ch" @@ -500,7 +503,7 @@ defmodule Ch.EctoTypeTest do end test "Polygon" do - assert {:parameterized, Ch, :polygon} = + assert {:parameterized, {Ch, :polygon}} = type = Ecto.ParameterizedType.init(Ch, type: "Polygon") assert Ecto.Type.type(type) == type @@ -517,7 +520,7 @@ defmodule Ch.EctoTypeTest do end test "MultiPolygon" do - assert {:parameterized, Ch, :multipolygon} = + assert {:parameterized, {Ch, :multipolygon}} = type = Ecto.ParameterizedType.init(Ch, type: "MultiPolygon") assert Ecto.Type.type(type) == type @@ -534,7 +537,7 @@ defmodule Ch.EctoTypeTest do end test "Decimal(18, 4)" do - assert {:parameterized, Ch, {:decimal, 18, 4}} = + assert {:parameterized, {Ch, {:decimal, 18, 4}}} = type = Ecto.ParameterizedType.init(Ch, type: unquote("Decimal(18, 4)")) assert Ecto.Type.type(type) == type @@ -547,7 +550,7 @@ defmodule Ch.EctoTypeTest do for size <- [32, 64, 128, 256] do test "Decimal#{size}(4)" do - assert {:parameterized, Ch, {unquote(:"decimal#{size}"), 4}} = + assert {:parameterized, {Ch, {unquote(:"decimal#{size}"), 4}}} = type = Ecto.ParameterizedType.init(Ch, type: unquote("Decimal#{size}(4)")) precision =