IF Commons GitHub

print

The printer (commons lang-sql 0009-sql-print FR-001 to FR-004): any node of the tree as text of a dialect, quoting an identifier and a string as the dialect does (0007-sql-emit), parenthesizing an expression where its binding power asks for it, so that the text is read back by the parser of the same dialect as the same tree but for its ranges. A construct that the dialect does not read is written as the printer's dialect has it; nothing here throws.

print(parse("select a from t where x = 1 or y = 2 and z = 3", ansi).script.statements[0]!, ansi);
// 'SELECT a FROM t WHERE x = 1 OR y = 2 AND z = 3'

Spec: 0009-sql-print FR-001, FR-003

Source: commons/lang-sql/src/print.ts

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

printfunction
function print(node: Node, dialect: Dialect, options?: PrintOptions): string

A node as text of a dialect.

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

printScriptfunction
function printScript(parsed: Parsed, dialect: Dialect, options?: PrintOptions): string

A script as text of a dialect: its statements ended by ;, a statement that could not be read by its source text.

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

PrintOptionsinterfaceno test imports it
interface PrintOptions

What the printer may be asked.

MemberTypeWhat it is
pretty?booleanEach clause of a query on a line of its own, indented by two spaces for each level.

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