Arcana.Ecto.Vector (Arcana v3.0.1)

Copy Markdown View Source

Drop-in wrapper around Pgvector.Ecto.Vector with a real equal?/2.

Pgvector.Ecto.Vector inherits Ecto's default equal?/2 (plain ==), so change detection compares terms structurally. Whenever the value loaded from the database isn't the exact representation being written back — a custom Postgrex types module decoding to a different struct, or list-vs-%Pgvector{} round trips — a byte-identical embedding always dirties the changeset, turning idempotent re-stores into write amplification plus HNSW index churn.

This type delegates type/cast/load/dump to Pgvector.Ecto.Vector (identical wire behavior) and compares values by their encoded binary, so byte-identical vectors are equal regardless of representation.

Values it can't encode (an opaque struct from a custom decoder that is neither enumerable nor castable) fall back to structural comparison, which is today's behavior rather than a crash.

If pgvector-elixir ships equal?/2 upstream (pgvector-python's Vector.__eq__ is the family precedent), this module becomes a no-op layer that can be dropped in a major release.

Summary

Functions

Callback implementation for Ecto.Type.cast/1.

Callback implementation for Ecto.Type.dump/1.

Callback implementation for Ecto.Type.embed_as/1.

Callback implementation for Ecto.Type.equal?/2.

Callback implementation for Ecto.Type.load/1.

Callback implementation for Ecto.Type.type/0.

Functions

cast(value)

Callback implementation for Ecto.Type.cast/1.

dump(value)

Callback implementation for Ecto.Type.dump/1.

embed_as(_)

Callback implementation for Ecto.Type.embed_as/1.

equal?(term1, term2)

Callback implementation for Ecto.Type.equal?/2.

load(data)

Callback implementation for Ecto.Type.load/1.

type()

Callback implementation for Ecto.Type.type/0.