package caqti

  1. Overview
  2. Docs

Module Caqti_querySource

Query specification.

Sourcetype t =
  1. | L of string
    (*

    Literal code. May contain incomplete fragments.

    *)
  2. | P of int
    (*

    P i refers to parameter number i, counting from 0.

    *)
  3. | S of t list
    (*

    S frags is the concatenation of frags.

    *)

A representation of a query string to send to a database, abstracting over parameter references and providing nested concatenation to simplify generation. For databases which only support linear parameters (typically denoted "?"), the driver will reshuffle, elide, and duplicate parameters as needed.

Sourceval normal : t -> t

normal q rewrites q to a normal form containing at most one top-level S constructor, containing no empty literals, and no consecutive literals. This function can be used to post-process queries before using equal and hash.

Sourceval equal : t -> t -> bool

Equality predicate for query.

Sourceval hash : t -> int

A hash function compatible with equal. This is currently Hashtbl.hash.

Sourceval pp : Format.formatter -> t -> unit

pp ppf q prints a human-readable representation of q on ppf.

Sourceval show : t -> string

show q is the same human-readable representation of q as printed by pp.

Sourceval concat : string -> t list -> t

concat sep frags is frags interfixed with sep if frags is non-empty and the empty string of frags is empty.

OCaml

Innovation. Community. Security.