Skip to content

Commit 0eee8a7

Browse files
committed
Attempt integration test
1 parent 3383f02 commit 0eee8a7

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
@@ -1300,10 +1300,17 @@ defmodule Ecto.Integration.RepoTest do
13001300
end
13011301

13021302
test "virtual field" do
1303-
assert %Post{id: id} = TestRepo.insert!(%Post{title: "1"})
1303+
assert %Post{id: id} = TestRepo.insert!(%Post{title: "1", temp: "special"})
13041304
assert TestRepo.get(Post, id).temp == "temp"
13051305
end
13061306

1307+
test "virtual embed" do
1308+
assert %Order{id: id, last_seen_item: %Item{reference: "1"}} =
1309+
TestRepo.insert!(%Order{last_seen_item: %Item{reference: "1"}})
1310+
1311+
assert %{last_seen_item: nil} = TestRepo.get(Order, id)
1312+
end
1313+
13071314
## Query syntax
13081315

13091316
defmodule Foo do

integration_test/support/schemas.exs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,13 +266,15 @@ defmodule Ecto.Integration.Order do
266266
* Embedding one schema
267267
* Preloading items inside embeds_many
268268
* Preloading items inside embeds_one
269+
* Virtual embeds
269270
* Field source with json_extract_path
270271
271272
"""
272273
use Ecto.Integration.Schema
273274

274275
schema "orders" do
275276
field :metadata, :map, source: :meta
277+
embeds_one :last_seen_item, Ecto.Integration.Item, virtual: true
276278
embeds_one :item, Ecto.Integration.Item
277279
embeds_many :items, Ecto.Integration.Item
278280
belongs_to :permalink, Ecto.Integration.Permalink

0 commit comments

Comments
 (0)