Skip to content

Commit acc9472

Browse files
committed
Add failing test for inserting via Ecto.Repo.insert!
It should be possible to use this function, and it did work as of ash v2.5.9. This test fails as of ash v2.5.10, which introduced adding relationships to underlying ecto schemas. The bug is related to a has_many relationship being present on the resource. The test fails with: 1) test call Ecto.Repo.insert! via Ash Repo (AshPostgres.EctoCompatibilityTest) test/ecto_compatibility_test.exs:6 ** (Ecto.InvalidChangesetError) could not perform insert because changeset is invalid. Errors %{posts: [{"is invalid", [type: {:array, :map}]}]} Applied changes %{name: "The Org"} Params nil Changeset #Ecto.Changeset< action: :insert, changes: %{name: "The Org"}, errors: [posts: {"is invalid", [type: {:array, :map}]}], data: #AshPostgres.Test.Organization<>, valid?: false > code: |> AshPostgres.TestRepo.insert!() stacktrace: (ecto 3.9.4) lib/ecto/repo/schema.ex:270: Ecto.Repo.Schema.insert!/4 test/ecto_compatibility_test.exs:9: (test)
1 parent 568fdb3 commit acc9472

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/ecto_compatibility_test.exs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
defmodule AshPostgres.EctoCompatibilityTest do
2+
use AshPostgres.RepoCase, async: false
3+
require Ash.Query
4+
5+
test "call Ecto.Repo.insert! via Ash Repo" do
6+
org =
7+
%AshPostgres.Test.Organization{name: "The Org"}
8+
|> AshPostgres.TestRepo.insert!()
9+
10+
assert org.name == "The Org"
11+
end
12+
end

0 commit comments

Comments
 (0)