IF Commons GitHub

sql/extensions/objects/objects

Written to: 4 requirements: 4 proved, 0 partly, 0 failing, 0 with no test recorded. 0048-sql-objects FR-001, 0048-sql-objects FR-002, 0048-sql-objects FR-003, 0048-sql-objects FR-004

The objects of a database that are not tables, views or indexes (commons data 0048-sql-objects): schemas, sequences, enumerated types, PostgreSQL's domains and extensions. Each is a value that says what it is; objectsSource writes them for a dialect that has them, in the setup group, before the tables, so that a table or a routine can use them. Each is made so that making it again changes nothing (PostgreSQL has no IF NOT EXISTS for a type or a domain, so those are guarded by a look at the catalog). An object a dialect cannot have is an error value naming it, unless the project says to carry it.

Source: commons/data/sql/extensions/objects/objects.ts

7 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.

canHavefunctionno test imports it
function canHave(dialect: Dialect, kind: "domain" | "enum" | "extension" | "schema" | "sequence"): boolean

Which kinds of object a dialect has.

DbObjecttypeno test imports it
type DbObject = | { readonly kind: "schema"; readonly name: string } | { readonly kind: "sequence"; readonly name: s… (647 characters)
type DbObject =
  | { readonly kind: "schema"; readonly name: string }
  | { readonly kind: "sequence"; readonly name: string; readonly schema?: string; readonly start?: number; readonly increment?: number; readonly cache?: number; readonly cycle?: boolean }
  | { readonly kind: "enum"; readonly name: string; readonly schema?: string; readonly values: readonly string[] }
  | { readonly kind: "domain"; readonly name: string; readonly schema?: string; readonly type: LogicalType; readonly notNull?: boolean; readonly default?: string; readonly check?: string }
  | { readonly kind: "extension"; readonly name: string; readonly schema?: string };

An object of a database.

enumOffunction
function enumOf(list: AnyCodeList, options?: { readonly schema?: string | undefined; readonly name?: string | undefined; }): (context: Pick<BindContext, "naming">) => DbObject

The enumerated type of a closed code list, its values written as the dialect's codes are (employed_by).

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

enumTypeconst
const enumType: (name: string, values: readonly string[], options?: { readonly schema?: string | undefined; }) => DbObject

An enumerated type: its values are what a column of it may hold, in order.

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

objectsSourcefunction
function objectsSource(objects: readonly (((c: Pick<BindContext, "naming">) => DbObject) | DbObject)[], settings?: ObjectsSettings): StatementSource

The statements of some objects.

ParameterWhat it is
objectsthe objects, or what makes them from the bind context (enumOf)
settingswhat a project says

Returns: a statement source

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

ObjectsSettingsinterfaceno test imports it
interface ObjectsSettings

What a project says of objects.

MemberTypeWhat it is
unsupported?"carry" | "refuse"What to do with an object the dialect cannot have: refuse (an error value, the default) or carry (nothing is written).
pgDomainconst
const pgDomain: (name: string, type: LogicalType, options?: { readonly schema?: string | undefined; readonly notNull?: boolean | undefined; readonly default?: string | undefined; readonly check?: string | undefined; }) => DbObject

A domain (PostgreSQL): a type with a rule, which a column or a routine can use as it uses the type.

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

schemaconst
const schema: (name: string) => DbObject

A schema.

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

sequenceconst
const sequence: (name: string, options?: { readonly schema?: string | undefined; readonly start?: number | undefined; readonly increment?: number | undefined; readonly cache?: number | undefined; readonly cycle?: boolean | undefined; }) => DbObject

A sequence of numbers.

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

statementOffunction
function statementOf(o: DbObject, dialect: Dialect): string

The statement that makes an object, for a dialect that has it.

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

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