IF Commons GitHub

aide/relational/mod

The engine of introspection (commons lang-sql 0008-sql-introspect FR-005, FR-006; 0010-aide FR-010): a small evaluator of the common ground of SQL over relations held in memory, so that a question about a tree is a query. It reads the query with this library's own parser, with the logic of SQL (null where a value is not known), and says in one sentence what it does not have. It sits behind Engine, which does not name the tree, and takes its relations from a Provider, so that any rows (a file tree, a list of checks, the tables of a machine) can be asked in SQL; it is read-only, and a statement that is not a query is an error value.

Spec: 0008-sql-introspect FR-005, FR-006

Source: commons/lang-sql/src/aide/relational/mod.ts

2 of 10 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

astsqlconstno test imports it
const astsql: Dialect

The dialect of the queries: the common ground.

createEnginefunction
function createEngine(tables: Provider, functions?: ReadonlyMap<string, ScalarFunction>, options?: EngineOptions): Engine

An engine over relations that a function gives by name (the relations are built when a query names them).

Imported by 24 tests of the run (24 passed, 0 failed): the library's results

Engineinterfaceno test imports it
interface Engine

Something that answers a query.

MemberTypeWhat it is
run(sql: string, params?: readonly Value[] | undefined) => Result<Table, QueryError>
QueryErrorinterfaceno test imports it
interface QueryError

What is wrong with a query, in one sentence.

MemberTypeWhat it is
messagestring
Rowstypeno test imports it
type Rows = Table;

What a query gives.

ScalarFunctiontypeno test imports it
type ScalarFunction = (args: readonly Value[]) => Value;

The functions a query may call besides the built-in ones of the engine.

Tableinterfaceno test imports it
interface Table

A relation: named columns and rows of values.

MemberTypeWhat it is
columnsreadonly string[]
rowsreadonly (readonly Value[])[]
Providertypeno test imports it
type Provider = (name: string) => Table | undefined;

Where relations come from: a function that gives the relation of a name, or undefined for a name it has not; it is asked when a query names the relation, so a provider may build it then.

providerOffunction
function providerOf(tables: Readonly<Record<string, Table>>): Provider

A provider of the relations of a record, found without regard to case.

Imported by 24 tests of the run (24 passed, 0 failed): the library's results

EngineOptionsinterfaceno test imports it
interface EngineOptions

What an engine may be given besides its relations and functions.

MemberTypeWhat it is
now?(() => Date)The clock CURRENT_DATE and the other current values are read from, once for each statement (the system clock where none is given).

Titles, headings, exports, tables, columns and requirements. Esc closes.