sql/extensions/convergence/read
Written to: 3 requirements: 3 proved, 0 partly, 0 failing, 0 with no test recorded. 0019-sql-convergence FR-001, 0019-sql-convergence FR-002, 0019-sql-convergence FR-003
Reading a database (commons data 0019-sql-convergence FR-001 to FR-003): the state a database is in, from its own catalog read by its dialect. A table and a column are found by the words of their names; a type that is the desired state's under another name is the desired state's; what the dialect cannot list is taken from the desired state, so that it is not a difference; and the state of a database made from the desired schema has the hash of the desired state.
Source: commons/data/sql/extensions/convergence/read.ts
4 of 7 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.
HOLDconstno test imports itconst HOLD: "@hold"
The entry of ignore that says to hold what the model does not name: a table, a column, an index or a constraint that is in the database and not in the state wanted is left out of the state read, so a plan never drops it, and is named in held. It is an entry of ignore so that every place that reads the database (the proposal, its application, the version gate and the automatic run) agrees.
normalDefaultfunctionno test imports itfunction normalDefault(text: string): string
A default as text, in the form two engines agree on: casts taken off, outer parentheses and spaces dropped, and what is not in quotes in lower case, so that 'x'::text, ('x') and 'x' are one, and CURRENT_TIMESTAMP and current_timestamp are one.
function normalizeType(t: string): string
A type with its synonyms put together, so that character varying(10) and VARCHAR(10) are the same.
Imported by 10 tests of the run (10 passed, 0 failed): the library's results
function readState(driver: Driver, dialect: Dialect, desired: State, options?: { readonly ignore?: readonly string[] | undefined; readonly held?: string[] | undefined; }): Promise<Result<State, readonly ReadError[]>>
The state a database is in.
| Parameter | What it is |
|---|
driver | the database |
dialect | its dialect, which reads its catalog |
desired | the state wanted, which names are matched to and types and what the dialect cannot list are taken from |
options | the names to leave out, where one that begins with * is a suffix |
Returns: the state, or why the dialect cannot read
Imported by 18 tests of the run (18 passed, 0 failed): the library's results
ReadErrortypeno test imports ittype ReadError = { readonly kind: "unsupported"; readonly why: string };
What is wrong with a read.
const sameType: (a: string, b: string) => boolean
Whether two written types are the same type.
Imported by 10 tests of the run (10 passed, 0 failed): the library's results
function spell(dialect: Dialect, live: string): string
A type as the dialect writes it, found from what the catalog calls it, so that a column that has no counterpart in the state wanted is still in the state's own spelling.
Imported by 10 tests of the run (10 passed, 0 failed): the library's results