-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Elixir version
Elixir 1.19.3 (compiled with Erlang/OTP 28)
Database and Version
PostgreSQL 16.11
Ecto Versions
ecto 3.13.5; ecto_sql 3.13.4
Database Adapter and Versions (postgrex, myxql, etc)
postgrex 0.21.1
Current behavior
I use raw sql query (using Ecto.Adapters.SQL.query) to query the postgres database and obtain data in which one of the columns is title alltags. I have a table in the database called "reports" and a schema file MyApp.Schemas.Report in which the alltags column is declared as a virtual field (please see below for the schema code).
When I try to map the query results to the Report schema defined below using the code:
fn row -> Repo.load(MyApp.Schemas.Report, Enum.zip(res.columns, row)) end)
then all columns other than alltags map fine, but the alltags column is nil (even though it is present in the results obtained from the raw query).
Thank you.
defmodule MyApp.Schemas.Report do
use Ecto.Schema
@primary_key {:id, :string, autogenerate: false}
schema "reports" do
field :author, :string
field :reporttxt, {:array, :string}
field :report_types, {:array, :map}
# Virtual fields
field :alltags, {:array, :string}, virtual: true
timestamps(type: :utc_datetime)
end
end
Expected behavior
I expect that the alltags column field will have the values returned by the raw database query.