Repo.load does not assign virtual fields


I know this works:

> Ecto.Type.load(:integer, 23)
{:ok, 23}
> Ecto.Type.load({:array, :integer}, [23])
{:ok, [23]}


defmodule Event do
  use Ecto.Schema
  schema "events" do
    field :survey_id, :integer, default: 0, virtual: true
    field :survey_ids, {:array, :integer}, default: [], virtual: true

This does not work:

> Repo.load(Event, {["survey_id", "survey_ids"], [23, [23]]})
%Event{__meta__: #Ecto.Schema.Metadata<:loaded, "events">, id: nil,
 survey_id: 0, survey_ids: []}

Are my expectations all wrong?


1 Like

This could be considered a bug. Please open an issue.

1 Like

I’m having the same problem

I there any update on this or an issue that can be tracked?

I’m using ecto 2.2.11

I’m sorry, I no longer work on the system I was working on when I submitted this question, so I did not push it through to resolution.

1 Like