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 @@ -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
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments