IF Commons GitHub

extensions/query/analysis

Named analyses of a syntax tree (commons lang-sql 0003-sql-ast-tools FR-007, FR-008): the tables a script reads, writes, creates, alters and drops, the functions it calls, and whether it is read-only.

A single name that is the name of a common table expression in scope is not a table. A common table expression is in scope in the body of its WITH, in the common table expressions after it, and, where the WITH is recursive, in its own and the others'. Names are compared without regard to case where they are not quoted, and as written where they are.

readOnlyProblem(parse("DELETE FROM t").script); // "it holds a DELETE"

Spec: 0003-sql-ast-tools FR-007, FR-008

Source: commons/lang-sql/src/extensions/query/analysis.ts

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

FunctionCallinterfaceno test imports it
interface FunctionCall

One call of a function.

MemberTypeWhat it is
namereadonly string[]
nodeCall
functionsCalledfunction
function functionsCalled(root: Node): readonly FunctionCall[]

Every call of a function in a tree, in the order of the text.

ParameterWhat it is
roota script, a statement or any node

Returns: the calls

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

readOnlyProblemfunction
function readOnlyProblem(script: Script): string | undefined

Why a script is not read-only, or nothing where it is: it holds one statement, and that is a query.

ParameterWhat it is
scriptthe script

Returns: one sentence, or undefined

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

TableAccesstypeno test imports it
type TableAccess = "read" | "write" | "create" | "alter" | "drop";

What a script does to a table.

TableUseinterfaceno test imports it
interface TableUse

One use of a table: its name as written, what is done to it, and the node.

MemberTypeWhat it is
namereadonly string[]
accessTableAccess
nodeNode
tableUsesfunction
function tableUses(root: Node): readonly TableUse[]

Every use of a table in a tree, in the order of the text.

ParameterWhat it is
roota script, a statement or any node

Returns: the uses

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

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