Skip to content

Commit 03c9300

Browse files
committed
Attempt integration test
1 parent 4757cb5 commit 03c9300

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

integration_test/cases/repo.exs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1308,10 +1308,17 @@ defmodule Ecto.Integration.RepoTest do
13081308
end
13091309

13101310
test "virtual field" do
1311-
assert %Post{id: id} = TestRepo.insert!(%Post{title: "1"})
1311+
assert %Post{id: id} = TestRepo.insert!(%Post{title: "1", temp: "special"})
13121312
assert TestRepo.get(Post, id).temp == "temp"
13131313
end
13141314

1315+
test "virtual embed" do
1316+
assert %Order{id: id, last_seen_item: %Item{reference: "1"}} =
1317+
TestRepo.insert!(%Order{last_seen_item: %Item{reference: "1"}})
1318+
1319+
assert %{last_seen_item: nil} = TestRepo.get(Order, id)
1320+
end
1321+
13151322
## Query syntax
13161323

13171324
defmodule Foo do

integration_test/support/schemas.exs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,15 @@ defmodule Ecto.Integration.Order do
275275
* Embedding one schema
276276
* Preloading items inside embeds_many
277277
* Preloading items inside embeds_one
278+
* Virtual embeds
278279
* Field source with json_extract_path
279280
280281
"""
281282
use Ecto.Integration.Schema
282283

283284
schema "orders" do
284285
field :metadata, :map, source: :meta
286+
embeds_one :last_seen_item, Ecto.Integration.Item, virtual: true
285287
embeds_one :item, Ecto.Integration.Item
286288
embeds_many :items, Ecto.Integration.Item
287289
belongs_to :permalink, Ecto.Integration.Permalink

0 commit comments

Comments
 (0)