SQL values and NULL #
This module fixes the values a cell of a SQL table can hold. A Value is a non-null value of one
of the three column types SqlType.int, SqlType.text and SqlType.bool; integers are
unbounded and text is a Lean String. A cell holds a Datum, which is Option Value: none is
SQL's NULL, which belongs to every type (Datum.HasType).
It adapts and redesigns material from sql_equiv (revision 38030a6b) by Evelyn Mitchell. There,
NULL was a value constructor carrying an optional type, and none : Option Value meant an
evaluation error. Here a value is never NULL, NULL is the none of a datum, errors are a
separate type (Cslib.SQL.EvalError), and decimals are not part of the fragment.
Main definitions #
Cslib.SQL.SqlType: the column typesint,textandbool.Cslib.SQL.Value: a non-null value, with its typeCslib.SQL.Value.type.Cslib.SQL.Datum: the content of a cell,Option Value, wherenoneisNULL.Cslib.SQL.Datum.HasType: a datum isNULLor a value of the given type.
An integer value is an integer literal.
A text value is a text literal.
A boolean value is a boolean literal.
The content of a cell: a value, or none for SQL's NULL.
It is an abbrev so that Option's constructors, instances (DecidableEq, Repr) and lemmas
apply to datums directly. The type does not encode errors: evaluation returns
Except EvalError Datum, so a NULL result and a failure stay distinct.