The record filter of a precise pull, shared by both ends of the protocol.
On the wire a filter is either "ids" (a list of key values) or an
integer range "id_start" / "id_end" (an open bound left out). Both
pull-data and table-records take it.
body/1— receiver side: builds the request fields from the:ids/:id_rangeoptions, refusing an empty or oversized filter before anything is requested.from_params/1— sender side: validates the request fields intonil,{:ids, values}or{:range, start, end}.where/3— sender side: the SQL condition on the table's single-column key. Values are compared in the key's own type, so the key's index is used: integers asbigint(the integer types compare across widths through the index), a uuid key takes uuid values, a text or varchar key takes text. A range needs an integer key; other key types do not take a filter.
Every value is a bind parameter; the key name arrives quoted.
Summary
Functions
Request fields for the :ids / :id_range options, or
{:error, :invalid_filter}: an :ids list that is empty, too long or
holds an unusable value, or a range without either bound. No option
means no filter (%{}).
Validates the filter fields of a request: {:ok, nil} when there are
none.
The most ids one filtered request may carry.
The condition for filter on the quoted key pk of SQL type key_type,
with its bind values, numbered from $1. {:error, :invalid_filter}
when a value does not fit the key (a non-integer id for an integer key,
a malformed uuid, a range on a non-integer key);
{:error, :unsupported_key_type} for a key type outside
smallint / integer / bigint / uuid / text / varchar.
Types
Functions
Request fields for the :ids / :id_range options, or
{:error, :invalid_filter}: an :ids list that is empty, too long or
holds an unusable value, or a range without either bound. No option
means no filter (%{}).
Validates the filter fields of a request: {:ok, nil} when there are
none.
@spec max_ids() :: pos_integer()
The most ids one filtered request may carry.
@spec where(t(), String.t(), String.t() | nil) :: {:ok, String.t(), list()} | {:error, :invalid_filter | :unsupported_key_type}
The condition for filter on the quoted key pk of SQL type key_type,
with its bind values, numbered from $1. {:error, :invalid_filter}
when a value does not fit the key (a non-integer id for an integer key,
a malformed uuid, a range on a non-integer key);
{:error, :unsupported_key_type} for a key type outside
smallint / integer / bigint / uuid / text / varchar.