Working-revision writes for posts.
Explicit nil attribute policy
Attribute maps distinguish an absent key from a key whose value is nil.
- An absent key never reaches the changeset, so the stored column is left untouched.
- An explicit
nilclears the column only for the fields listed in[:excerpt, :featured_image_url, :featured_image_alt, :reading_time_minutes, :publish_at], which are exactly the nullable optional revision columns. This is what makes a scheduledpublish_atunschedulable. - An explicit
nilfor any other field (includingtag_ids,featured, and the required content fields) is ignored exactly as if the key had been omitted. That keepstag_ids: nilmeaning "keep the current tags" and keepsNOT NULLcolumns such asfeaturedon their stored value or schema default.
Summary
Functions
Rewrites (or clones) the working revision of a post.
Types
@type edit() :: %{ blog: BlogEngine.Schema.Blog.t(), before: BlogEngine.Schema.Post.t(), post: BlogEngine.Schema.Post.t(), revision: BlogEngine.Schema.PostRevision.t(), route_changed?: boolean() }
Successful update_working/7 payload.
@type failure() :: BlogEngine.Error.t() | Ecto.Changeset.t()
Failure reason returned by revision writes.
Functions
@spec update_working( module(), BlogEngine.Context.t(), Ecto.UUID.t(), Ecto.UUID.t(), map(), boolean(), (BlogEngine.Schema.Post.t() -> :ok | {:error, failure()}) ) :: {:ok, edit()} | {:error, failure()}
Rewrites (or clones) the working revision of a post.
The active-author requirement only applies when attrs supplies an
:author_id that differs from the current working source. Editing content
without reassigning authorship therefore keeps working after the original
author is deactivated. Reassigning to a deactivated same-tenant author fails
with :author_inactive; an unknown or foreign-tenant author fails with
:not_found.
See the module documentation for how explicit nil attribute values are
interpreted.