Skip to content

Commit

Permalink
Improve force_change/put_change/update_change docs
Browse files Browse the repository at this point in the history
Closes #4292.
  • Loading branch information
josevalim committed Oct 3, 2023
1 parent 6bacf49 commit 344793a
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions lib/ecto/changeset.ex
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,8 @@ defmodule Ecto.Changeset do
your additional empty values
* `:force_changes` - a boolean indicating whether to include values that don't alter
the current data in `:changes`. Defaults to `false`
the current data in `:changes`. See `force_change/3` for more information, Defaults
to `false`
* `:message` - a function of arity 2 that is used to create the error message when
casting fails. It is called for every field that cannot be casted and receives the
Expand Down Expand Up @@ -1795,8 +1796,11 @@ defmodule Ecto.Changeset do
Updates a change.
The given `function` is invoked with the change value only if there
is a change for `key`. Note that the value of the change
can still be `nil` (unless the field was marked as required on `validate_required/3`).
is a change for `key`. Once the function is invoked, it behaves as
`put_changed/3`.
Note that the value of the change can still be `nil` (unless the field
was marked as required on `validate_required/3`).
## Examples
Expand Down Expand Up @@ -1828,7 +1832,8 @@ defmodule Ecto.Changeset do
If the change is already present, it is overridden with
the new value. If the change has the same value as in the
changeset data, it is not added to the list of changes.
changeset data, no changes are added (and any existing
changes are removed).
When changing embeds and associations, see `put_assoc/4`
for a complete reference on the accepted values.
Expand Down Expand Up @@ -2120,7 +2125,10 @@ defmodule Ecto.Changeset do
Forces a change on the given `key` with `value`.
If the change is already present, it is overridden with
the new value.
the new value. If the value is later modified via
`put_change/3` and `update_change/3`, revering back to
its original value, the change will be reverted unless
`force_change/3` is called once again.
## Examples
Expand Down

1 comment on commit 344793a

@jivko-chobanov
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in docs:

L1800: Once the function is invoked, it behaves as put_changed/3.

put_changed/3 should be put_change/3

Please sign in to comment.