File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments