Ash.Changeset.select
select
, go back to Ash.Changeset module for more information.
Ensure that only the specified attributes are present in the results.
The first call to select/2
will replace the default behavior of selecting
all attributes. Subsequent calls to select/2
will combine the provided
fields unless the replace?
option is provided with a value of true
.
If a field has been deselected, selecting it again will override that (because a single list of fields is tracked for selection)
Primary key attributes always selected and cannot be deselected.
When attempting to load a relationship (or manage it with Ash.Changeset.manage_relationship/3
),
if the source field is not selected on the query/provided data an error will be produced. If loading
a relationship with a query, an error is produced if the query does not select the destination field
of the relationship.
Datalayers currently are not notified of the select
for a changeset(unlike queries), and creates/updates select all fields when they are performed.
A select provided on a changeset simply sets the unselected fields to nil
before returning the result.
Use ensure_selected/2
if you simply wish to make sure a field has been selected, without deselecting any other fields.