The documentation for Ecto.Schema
says the following about the :virtual
option:
:virtual
- When true, the field is not persisted to the database.
The embedded_schema/1
function says that it describes a schema kept exclusively in-memory. (i.e. It is never persisted to the DB.) Does that mean that for embedded schemas, the :virtual
option has no effect?
The documentation on Ecto.Schema.#embedded_schema/1
actually says:
An embedded schema is either embedded into another schema or kept exclusively in memory. For this reason, an embedded schema does not require a source name and it does not include a metadata field.
When embedded into another schema, it acts as a snippet directly injected into the target schema, and :virtual
fields act as usual.
When kept in memory, :virtual
fields do still
:any
, unlike other fields__schema__(:fields)
__schema__(:type, field)
:autogenerate
nor :read_after_writes
options