Liking cljdoc? Tell your friends :D

datahike.pg.sql.types

Parsers for CREATE TYPE … AS ENUM (…) and CREATE DOMAIN. Both bypass JSqlParser (which can't / doesn't parse them) and produce parsed maps the server's exec-* dispatch picks up.

Mirrors the shape of datahike.pg.sql.database (CREATE DATABASE): classify routes the statement to a system-type bypass, this ns tokenises and extracts the structured form, the server transacts it as a registry entity (:datahike.pg.enum/* or :datahike.pg.domain/*).

Why registry entities and not native Datahike types: enums are semantically string + check-in <values>; domains are <base-type> + optional CHECK. Both can be lowered transparently when a column references them in CREATE TABLE — column-type resolution looks the name up in the registry and expands. The dump tool reads the registry back and emits CREATE TYPE / CREATE DOMAIN headers before tables, so the round trip preserves the full schema.

Parsers for `CREATE TYPE … AS ENUM (…)` and `CREATE DOMAIN`. Both
bypass JSqlParser (which can't / doesn't parse them) and produce
parsed maps the server's exec-* dispatch picks up.

Mirrors the shape of `datahike.pg.sql.database` (CREATE DATABASE):
classify routes the statement to a system-type bypass, this ns
tokenises and extracts the structured form, the server transacts
it as a registry entity (`:datahike.pg.enum/*` or
`:datahike.pg.domain/*`).

Why registry entities and not native Datahike types: enums are
semantically `string + check-in <values>`; domains are
`<base-type> + optional CHECK`. Both can be lowered transparently
when a column references them in CREATE TABLE — column-type
resolution looks the name up in the registry and expands. The
dump tool reads the registry back and emits CREATE TYPE / CREATE
DOMAIN headers before tables, so the round trip preserves the
full schema.
raw docstring

parse-create-domainclj

(parse-create-domain toks original-sql)

Parse CREATE DOMAIN [schema.]name AS <base-type> [<modifiers>...].

Modifiers we capture:

  • CONSTRAINT <name> CHECK (<expr>) → :check-name + :check-expr
  • CHECK (<expr>) → :check-expr (anonymous)
  • NOT NULL / NULL → :not-null
  • DEFAULT <expr> → :default-raw

Returns: {:domain-name str :base-type str ; lower-case base-type name as written :base-args [str ...] ; type args if any (e.g. NUMERIC(10,2)) :check-name str | nil :check-expr str | nil ; SQL fragment between parens :not-null bool :default-raw str | nil :original-sql str}

Multiple constraints are not supported — first wins.

Parse `CREATE DOMAIN [schema.]name AS <base-type> [<modifiers>...]`.

Modifiers we capture:
  - `CONSTRAINT <name> CHECK (<expr>)`  → :check-name + :check-expr
  - `CHECK (<expr>)`                    → :check-expr (anonymous)
  - `NOT NULL` / `NULL`                 → :not-null
  - `DEFAULT <expr>`                    → :default-raw

Returns:
  {:domain-name str
   :base-type   str         ; lower-case base-type name as written
   :base-args   [str ...]   ; type args if any (e.g. NUMERIC(10,2))
   :check-name  str | nil
   :check-expr  str | nil   ; SQL fragment between parens
   :not-null    bool
   :default-raw str | nil
   :original-sql str}

Multiple constraints are not supported — first wins.
sourceraw docstring

parse-create-type-enumclj

(parse-create-type-enum toks original-sql)

Parse a tokenised CREATE TYPE [schema.]name AS ENUM ('v1', 'v2', …) statement. Returns:

{:type-name string ; unqualified :values [string …] ; in declaration order :original-sql string} ; for re-emission

Throws ex-info with :error :syntax-error on malformed input.

Parse a tokenised `CREATE TYPE [schema.]name AS ENUM ('v1', 'v2', …)`
statement. Returns:

  {:type-name string                      ; unqualified
   :values    [string …]                  ; in declaration order
   :original-sql string}                  ; for re-emission

Throws ex-info with `:error :syntax-error` on malformed input.
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