IF Commons GitHub

sql/extensions/routines/routine

Written to: 3 requirements: 3 proved, 0 partly, 0 failing, 0 with no test recorded. 0009-sql-features FR-011, 0009-sql-features FR-012, 0009-sql-features FR-013

Routines (commons data 0009-sql-features FR-011 to FR-013): a function or procedure with typed parameters and a body that is text and typed references. A reference to a table, a column of a table or a parameter is written by the case style as the name that table, column or parameter has, so a body never holds a name by hand that the case style could write differently.

Source: commons/data/sql/extensions/routines/routine.ts

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

columnconst
const column: (tableName: string, columnName: string) => Ref

A reference to a column of a table, as governance names them.

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

columnNameconst
const columnName: (tableName: string, columnName_: string) => Ref

A reference to the name of a column alone, where SQL does not take it qualified (the target of SET).

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

paramconst
const param: (name: string) => Ref

A reference to a parameter of the routine, written with the routine's name before it.

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

routinesSourcefunction
function routinesSource(definitions: readonly RoutineDefinition[]): StatementSource

The source of routines.

ParameterWhat it is
definitionsthe routines, in the order they are made

Returns: a statement source

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

tableconst
const table: (name: string) => Ref

A reference to a table, as governance names it.

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

Paraminterfaceno test imports it
interface Param

A parameter.

MemberTypeWhat it is
namestring
typeLogicalType
Reftypeno test imports it
type Ref = | { readonly ref: "table"; readonly table: string } | { readonly ref: "column"; readonly table: string; r… (701 characters)
type Ref =
  | { readonly ref: "table"; readonly table: string }
  | { readonly ref: "column"; readonly table: string; readonly column: string }
  | { readonly ref: "columnName"; readonly table: string; readonly column: string }
  | { readonly ref: "param"; readonly param: string }
  /** A variable of a block, by its name as governance writes names (0050-sql-plpgsql). */
  | { readonly ref: "var"; readonly name: string }
  /** A type, written for the dialect. */
  | { readonly ref: "type"; readonly type: LogicalType }
  /** A column of a record a loop gives, by the table it is a row of. */
  | { readonly ref: "field"; readonly record: string; readonly table: string; readonly column: string };

A reference in a body.

Returnstypeno test imports it
type Returns =
  | { readonly type: LogicalType }
  | { readonly setOf: string }
  | { readonly columns: readonly { readonly name: string; readonly type: LogicalType }[] };

What a function returns: a type, the rows of a table, or rows of columns.

RoutineDefinitioninterface
interface RoutineDefinition

A routine.

MemberTypeWhat it is
kind"function" | "procedure"
namestringIts name as governance writes names, lower camel case.
descriptionstring
params?readonly Param[]
returns?ReturnsWhat a function returns; a procedure returns nothing.
language"plpgsql" | "sql"
volatility?"immutable" | "stable" | "volatile"
bodyreadonly (string | Ref)[]

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

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