Liking cljdoc? Tell your friends :D

datahike.pg.records

Composite / record values (PG record 2249 and named composite types).

A PgRecord carries its field values plus each field's OID and the record's own type OID (2249 for an anonymous ROW(...), or a named composite type's OID). The OIDs are needed for the binary wire codec (PG's record binary format is [nfields][per-field oid,len,data]); the values render to PG's canonical record_out text for text-format clients. Mirrors the role datahike.pg.arrays/PgArray plays for arrays.

Composite / record values (PG `record` 2249 and named composite types).

A `PgRecord` carries its field values plus each field's OID and the
record's own type OID (2249 for an anonymous `ROW(...)`, or a named
composite type's OID). The OIDs are needed for the binary wire codec
(PG's record binary format is [nfields][per-field oid,len,data]); the
values render to PG's canonical `record_out` text for text-format
clients. Mirrors the role `datahike.pg.arrays/PgArray` plays for arrays.
raw docstring

field-valueclj

(field-value r fname)

The value of the field fname of a record: by name when the record has names, else by PostgreSQL's positional fN spelling. Returns ::absent when the record has no such field, which the caller reports as 42703.

The value of the field `fname` of a record: by name when the record
has names, else by PostgreSQL's positional `fN` spelling. Returns
::absent when the record has no such field, which the caller reports
as 42703.
sourceraw docstring

from-pg-textclj

(from-pg-text s)

The raw field cells of PG's canonical record text (a,b,"c,d",), in order. A quoted cell is unescaped ("" → ", \x → x); an UNQUOTED empty cell is nil, which is how record_in reads SQL NULL; a quoted empty cell is the empty string. Returns nil when s is not record text, so a caller can fall through to its other cases.

The raw field cells of PG's canonical record text `(a,b,"c,d",)`, in
order. A quoted cell is unescaped (`""` → `"`, `\x` → `x`); an
UNQUOTED empty cell is nil, which is how `record_in` reads SQL NULL;
a quoted empty cell is the empty string. Returns nil when `s` is not
record text, so a caller can fall through to its other cases.
sourceraw docstring

layoutclj

(layout r)

A record's [name oid] pairs -- what canonical text loses.

A record's [name oid] pairs -- what canonical text loses.
sourceraw docstring

layout->textclj

(layout->text lay)

A layout as one string, for a schema entity: name:oid per field, comma separated, the name left empty for an anonymous ROW's field.

A layout as one string, for a schema entity: `name:oid` per field,
comma separated, the name left empty for an anonymous ROW's field.
sourceraw docstring

make-recordclj

(make-record oid-fn values)
(make-record oid-fn values type-oid)

Build a PgRecord from a seq of field values, inferring each field's OID via oid-fn (a value->oid function, e.g. types/infer-oid-from-value). type-oid defaults to 2249 (anonymous record).

Build a PgRecord from a seq of field values, inferring each field's OID
via `oid-fn` (a value->oid function, e.g. types/infer-oid-from-value).
`type-oid` defaults to 2249 (anonymous record).
sourceraw docstring

named-recordclj

(named-record names+oids+values)

A PgRecord whose fields carry NAMES, for the composite values SQL can select a field out of: (information_schema._pg_expandarray(a)).n. An anonymous ROW has no names -- PostgreSQL calls those fields f1, f2, … and field-value falls back to that.

A PgRecord whose fields carry NAMES, for the composite values SQL can
select a field out of: `(information_schema._pg_expandarray(a)).n`.
An anonymous ROW has no names -- PostgreSQL calls those fields f1, f2,
… and `field-value` falls back to that.
sourceraw docstring

record?clj

(record? v)
source

register-layouts!clj

(register-layouts! reg-fn r)

Recursively register each PgRecord's field OIDs (via reg-fn — a 2-arg fn [record-text int-array-of-field-oids], i.e. PgParamCodec/registerRecordLayout) keyed by its canonical record_out text. Lets the anonymous-record binary encoder recover the per-field OIDs the text alone can't carry.

Recursively register each PgRecord's field OIDs (via `reg-fn` — a 2-arg fn
[record-text int-array-of-field-oids], i.e. PgParamCodec/registerRecordLayout)
keyed by its canonical record_out text. Lets the anonymous-record binary
encoder recover the per-field OIDs the text alone can't carry.
sourceraw docstring

text->layoutclj

(text->layout s)

Inverse of layout->text.

Inverse of `layout->text`.
sourceraw docstring

text->recordclj

(text->record s lay parse-fn)

Rebuild a PgRecord from canonical text. Each field is read with its OID's input function when lay names one and the type has one; otherwise the cell stays text -- a value that renders identically and only loses the field's declared type. nil when s is not record text.

Rebuild a PgRecord from canonical text. Each field is read with its
OID's input function when `lay` names one and the type has one;
otherwise the cell stays text -- a value that renders identically and
only loses the field's declared type. nil when `s` is not record text.
sourceraw docstring

to-pg-textclj

(to-pg-text r)

Render a PgRecord to PG's canonical record_out text: (f1,f2,...).

Render a PgRecord to PG's canonical `record_out` text: `(f1,f2,...)`.
sourceraw docstring

with-layoutclj

(with-layout record type-oid field-oids)

Retag an anonymous record with a named composite type and its declared field OIDs. Composite casts need this metadata after expression lowering: the values alone cannot distinguish, for example, text from point, because both currently use a string JVM carrier.

Retag an anonymous record with a named composite type and its declared
field OIDs. Composite casts need this metadata after expression lowering:
the values alone cannot distinguish, for example, `text` from `point`,
because both currently use a string JVM carrier.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close