-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed as not planned
Labels
Description
Elixir version
Elixir 1.16.0 (compiled with Erlang/OTP 26)
Database and Version
PostgreSQL 14
Ecto Versions
ecto 3.11.1
Database Adapter and Versions (postgrex, myxql, etc)
postgrex 0.17.4
Current behavior
- I perform a complex manual query to retrieve some data, this data includes additional fields relevant to my Schema in this data context.
query = `BIG SCARY SQL`
%{columns: columns, rows: rows} = Repo.query!(query)
- I iterate over the rows to load the data into my Struct, including the additional fields as virtual fields.
for row <- rows do
casted_data = Repo.load(MyStruct, {columns, row})
## IO.inspect(casted_data)
## %MyStruct{persisted_field: "foo", virtual_field: nil}
end
Expected behavior
As the Schema as just one of the representations of my data in this context and not the actual database table itself I should be able to load not just the fields present in the database to my struct using Repo.load/2
.