Skip to content

Commit e32ebf8

Browse files
committed
Depend on Ecto v3.8.0-dev
1 parent fd8d852 commit e32ebf8

10 files changed

Lines changed: 72 additions & 16 deletions

File tree

integration_test/myxql/myxql_type_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
defmodule Ecto.Integration.MyXQLTypeTest do
2-
use Ecto.Integration.Case, async: Application.get_env(:ecto, :async_integration_tests, true)
2+
use Ecto.Integration.Case, async: Application.compile_env(:ecto, :async_integration_tests, true)
33
alias Ecto.Integration.TestRepo
44
import Ecto.Query
55

integration_test/sql/sandbox.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ defmodule Ecto.Integration.SandboxTest do
77

88
import ExUnit.CaptureLog
99

10-
Application.put_env(:ecto_sql, __MODULE__.DynamicRepo, Application.get_env(:ecto_sql, TestRepo))
10+
Application.put_env(:ecto_sql, __MODULE__.DynamicRepo, Application.compile_env(:ecto_sql, TestRepo))
1111

1212
defmodule DynamicRepo do
1313
use Ecto.Repo, otp_app: :ecto_sql, adapter: TestRepo.__adapter__()

integration_test/sql/stream.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
defmodule Ecto.Integration.StreamTest do
2-
use Ecto.Integration.Case, async: Application.get_env(:ecto, :async_integration_tests, true)
2+
use Ecto.Integration.Case, async: Application.compile_env(:ecto, :async_integration_tests, true)
33

44
alias Ecto.Integration.TestRepo
55
alias Ecto.Integration.Post

integration_test/sql/subquery.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
defmodule Ecto.Integration.SubQueryTest do
2-
use Ecto.Integration.Case, async: Application.get_env(:ecto, :async_integration_tests, true)
2+
use Ecto.Integration.Case, async: Application.compile_env(:ecto, :async_integration_tests, true)
33

44
alias Ecto.Integration.TestRepo
55
import Ecto.Query

lib/ecto/adapters/sql.ex

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -649,10 +649,12 @@ defmodule Ecto.Adapters.SQL do
649649
def insert_all(adapter_meta, schema_meta, conn, header, rows, on_conflict, returning, placeholders, opts) do
650650
%{source: source, prefix: prefix} = schema_meta
651651
{_, conflict_params, _} = on_conflict
652-
{rows, params} = case rows do
653-
{%Ecto.Query{} = query, params} -> {query, Enum.reverse(params)}
654-
rows -> unzip_inserts(header, rows)
655-
end
652+
653+
{rows, params} =
654+
case rows do
655+
{%Ecto.Query{} = query, params} -> {query, Enum.reverse(params)}
656+
rows -> unzip_inserts(header, rows)
657+
end
656658

657659
sql = conn.insert(prefix, source, header, rows, on_conflict, returning, placeholders)
658660

@@ -663,9 +665,8 @@ defmodule Ecto.Adapters.SQL do
663665
end
664666

665667
all_params = placeholders ++ Enum.reverse(params, conflict_params)
666-
%{num_rows: num, rows: rows} =
667-
query!(adapter_meta, sql, all_params, opts)
668668

669+
%{num_rows: num, rows: rows} = query!(adapter_meta, sql, all_params, opts)
669670
{num, rows}
670671
end
671672

mix.exs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ defmodule EctoSQL.MixProject do
22
use Mix.Project
33

44
@source_url "https://github.com/elixir-ecto/ecto_sql"
5-
@version "3.7.1"
5+
@version "3.8.0-dev"
66
@adapters ~w(pg myxql tds)
77

88
def project do
99
[
1010
app: :ecto_sql,
1111
version: @version,
12-
elixir: "~> 1.8",
12+
elixir: "~> 1.9",
1313
deps: deps(),
1414
test_paths: test_paths(System.get_env("ECTO_ADAPTER")),
1515
xref: [
@@ -77,7 +77,7 @@ defmodule EctoSQL.MixProject do
7777
if path = System.get_env("ECTO_PATH") do
7878
{:ecto, path: path}
7979
else
80-
{:ecto, "~> 3.7.0"}
80+
{:ecto, "~> 3.8.0-dev", github: "elixir-ecto/ecto"}
8181
end
8282
end
8383

mix.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
"decimal": {:hex, :decimal, "1.9.0", "83e8daf59631d632b171faabafb4a9f4242c514b0a06ba3df493951c08f64d07", [:mix], [], "hexpm", "b1f2343568eed6928f3e751cf2dffde95bfaa19dd95d09e8a9ea92ccfd6f7d85"},
77
"deep_merge": {:hex, :deep_merge, "0.2.0", "c1050fa2edf4848b9f556fba1b75afc66608a4219659e3311d9c9427b5b680b3", [:mix], [], "hexpm", "e3bf435a54ed27b0ba3a01eb117ae017988804e136edcbe8a6a14c310daa966e"},
88
"earmark_parser": {:hex, :earmark_parser, "1.4.16", "607709303e1d4e3e02f1444df0c821529af1c03b8578dfc81bb9cf64553d02b9", [:mix], [], "hexpm", "69fcf696168f5a274dd012e3e305027010658b2d1630cef68421d6baaeaccead"},
9-
"ecto": {:hex, :ecto, "3.7.0", "0b250b4aa5a9cdb80252802bd535c54c963e2d83f5bd179a57c093ed0779994b", [:mix], [{:decimal, "~> 1.6 or ~> 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", "3a212cecd544a6f3d00921bc3e7545070eb50b9a1454525323027bf07eba1165"},
9+
"ecto": {:git, "https://github.com/elixir-ecto/ecto.git", "5b2abf83cb730d29c10a1bb3522226caadd6d1b6", []},
1010
"ex_doc": {:hex, :ex_doc, "0.25.3", "3edf6a0d70a39d2eafde030b8895501b1c93692effcbd21347296c18e47618ce", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "9ebebc2169ec732a38e9e779fd0418c9189b3ca93f4a676c961be6c1527913f5"},
11-
"jason": {:hex, :jason, "1.2.2", "ba43e3f2709fd1aa1dce90aaabfd039d000469c05c56f0b8e31978e03fa39052", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "18a228f5f0058ee183f29f9eae0805c6e59d61c3b006760668d8d18ff0d12179"},
11+
"jason": {:hex, :jason, "1.3.0", "fa6b82a934feb176263ad2df0dbd91bf633d4a46ebfdffea0c8ae82953714946", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "53fc1f51255390e0ec7e50f9cb41e751c260d065dcba2bf0d08dc51a4002c2ac"},
1212
"makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"},
1313
"makeup_elixir": {:hex, :makeup_elixir, "0.15.1", "b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"},
1414
"makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
@@ -17,5 +17,5 @@
1717
"poison": {:hex, :poison, "4.0.1", "bcb755a16fac91cad79bfe9fc3585bb07b9331e50cfe3420a24bcc2d735709ae", [:mix], [], "hexpm", "ba8836feea4b394bb718a161fc59a288fe0109b5006d6bdf97b6badfcf6f0f25"},
1818
"postgrex": {:hex, :postgrex, "0.15.5", "aec40306a622d459b01bff890fa42f1430dac61593b122754144ad9033a2152f", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "ed90c81e1525f65a2ba2279dbcebf030d6d13328daa2f8088b9661eb9143af7f"},
1919
"tds": {:hex, :tds, "2.1.1", "b6163ea716d74ed90a3a83668db2e7c74c1e722fd3538ef5758e0a084fde8d60", [:mix], [{:db_connection, "~> 2.0", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.6", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "6b28e1f06a57867eb6b1a957ae5d872b09214ba771ef08cf5ca9d52d6d372876"},
20-
"telemetry": {:hex, :telemetry, "0.4.3", "a06428a514bdbc63293cd9a6263aad00ddeb66f608163bdec7c8995784080818", [:rebar3], [], "hexpm", "eb72b8365ffda5bed68a620d1da88525e326cb82a75ee61354fc24b844768041"},
20+
"telemetry": {:hex, :telemetry, "1.0.0", "0f453a102cdf13d506b7c0ab158324c337c41f1cc7548f0bc0e130bbf0ae9452", [:rebar3], [], "hexpm", "73bc09fa59b4a0284efb4624335583c528e07ec9ae76aca96ea0673850aec57a"},
2121
}

test/ecto/adapters/myxql_test.exs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,24 @@ defmodule Ecto.Adapters.MyXQLTest do
711711
end
712712
end
713713

714+
test "update all with subquery" do
715+
sub = from(p in Schema, where: p.x > ^10)
716+
717+
query =
718+
Schema
719+
|> join(:inner, [p], p2 in subquery(sub), on: p.id == p2.id)
720+
|> update([_], set: [x: ^100])
721+
722+
{planned_query, params} = Ecto.Adapter.Queryable.plan_query(:update_all, Ecto.Adapters.MyXQL, query)
723+
724+
assert update_all(planned_query) ==
725+
~s{UPDATE `schema` AS s0, } <>
726+
~s{(SELECT ss0.`id` AS `id`, ss0.`x` AS `x`, ss0.`y` AS `y`, ss0.`z` AS `z`, ss0.`meta` AS `meta` FROM `schema` AS ss0 WHERE (ss0.`x` > ?)) AS s1 } <>
727+
~s{SET s0.`x` = ? WHERE (s0.`id` = s1.`id`)}
728+
729+
assert params == [10, 100]
730+
end
731+
714732
test "update all with prefix" do
715733
query = from(m in Schema, update: [set: [x: 0]]) |> Map.put(:prefix, "prefix") |> plan(:update_all)
716734
assert update_all(query) == ~s{UPDATE `prefix`.`schema` AS s0 SET s0.`x` = 0}

test/ecto/adapters/postgres_test.exs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,25 @@ defmodule Ecto.Adapters.PostgresTest do
828828
~s{UPDATE "schema" AS s0 SET "w" = array_remove(s0."w", 0)}
829829
end
830830

831+
test "update all with subquery" do
832+
sub = from(p in Schema, where: p.x > ^10)
833+
834+
query =
835+
Schema
836+
|> join(:inner, [p], p2 in subquery(sub), on: p.id == p2.id)
837+
|> update([_], set: [x: ^100])
838+
839+
{planned_query, params} =
840+
Ecto.Adapter.Queryable.plan_query(:update_all, Ecto.Adapters.Postgres, query)
841+
842+
assert update_all(planned_query) ==
843+
~s{UPDATE "schema" AS s0 SET "x" = $2 FROM } <>
844+
~s{(SELECT ss0."id" AS "id", ss0."x" AS "x", ss0."y" AS "y", ss0."z" AS "z", ss0."w" AS "w", ss0."meta" AS "meta" FROM "schema" AS ss0 WHERE (ss0."x" > $1)) } <>
845+
~s{AS s1 WHERE (s0."id" = s1."id")}
846+
847+
assert params == [10, 100]
848+
end
849+
831850
test "update all with prefix" do
832851
query = from(m in Schema, update: [set: [x: 0]]) |> Map.put(:prefix, "prefix") |> plan(:update_all)
833852
assert update_all(query) ==

test/ecto/adapters/tds_test.exs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,24 @@ defmodule Ecto.Adapters.TdsTest do
840840
~s{INNER JOIN [schema2] AS s1 ON s0.[x] = s1.[z] WHERE (s0.[x] = 123)}
841841
end
842842

843+
test "update all with subquery" do
844+
sub = from(p in Schema, where: p.x > ^10)
845+
846+
query =
847+
Schema
848+
|> join(:inner, [p], p2 in subquery(sub), on: p.id == p2.id)
849+
|> update([_], set: [x: ^100])
850+
851+
{planned_query, params} = Ecto.Adapter.Queryable.plan_query(:update_all, Ecto.Adapters.Tds, query)
852+
853+
assert update_all(planned_query) ==
854+
~s{UPDATE s0 SET s0.[x] = @2 FROM [schema] AS s0 INNER JOIN } <>
855+
~S{(SELECT ss0.[id] AS [id], ss0.[x] AS [x], ss0.[y] AS [y], ss0.[z] AS [z], ss0.[w] AS [w] FROM [schema] AS ss0 WHERE (ss0.[x] > @1)) } <>
856+
~S{AS s1 ON s0.[id] = s1.[id]}
857+
858+
assert params == [10, 100]
859+
end
860+
843861
test "update all with returning" do
844862
query = from(m in Schema, update: [set: [x: 0]]) |> select([m], m) |> plan(:update_all)
845863

0 commit comments

Comments
 (0)