Ecto.StaleEntryError 更新时
Ecto.StaleEntryError when updating
有时我在尝试更新记录时得到 (Ecto.StaleEntryError) attempted to update a stale struct
。
我没有在 Ecto 的文档中找到任何避免这种情况的方法,那么我应该怎么做才能避免这种情况?
P.S。我正在通过 Postgrex、Ecto 2.1.3 使用 PostgreSQL 9.6。
看起来您正在从数据库中获取架构并在您的应用程序中的其他地方更新后对其进行更新。您是否正在获取、挂在上面并稍后更新?如果是,请获取、更改和更新。
来自 Ecto 文档:
When a conflict happens (a record which has been previously fetched is
being updated, but that same record has been modified since it was
fetched), an `Ecto.StaleEntryError` exception is raised.
有时我在尝试更新记录时得到 (Ecto.StaleEntryError) attempted to update a stale struct
。
我没有在 Ecto 的文档中找到任何避免这种情况的方法,那么我应该怎么做才能避免这种情况?
P.S。我正在通过 Postgrex、Ecto 2.1.3 使用 PostgreSQL 9.6。
看起来您正在从数据库中获取架构并在您的应用程序中的其他地方更新后对其进行更新。您是否正在获取、挂在上面并稍后更新?如果是,请获取、更改和更新。
来自 Ecto 文档:
When a conflict happens (a record which has been previously fetched is
being updated, but that same record has been modified since it was
fetched), an `Ecto.StaleEntryError` exception is raised.