Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0003-sql-port FR-002
The statements of a store, built by the language of SQL: a name is written by identifier of the dialect, a parameter by placeholder in the order it is added, and no value is ever part of the text, so that a path or a prefix with a quote, a percent sign or a backslash in it is only a value. Each dialect differs in three small things the builder hides: the type a column has, how bytes are given to the engine (DuckDB takes them as hex, since it cannot type a binary parameter) and how a row is locked for writing (PostgreSQL's FOR UPDATE).
import { sqlFor } from"./sql.ts";
constsql=sqlFor("postgres", naming);
sql.query().text("SELECT rev FROM ").table("objects").text(" WHERE path = ").param("a").done();
// { text: 'SELECT rev FROM anyfs_objects WHERE path = $1', params: ["a"] }
type Query = {
/** Adds text written by this library (a keyword, an operator): never a value and never a name. */
te…(908 characters)
typeQuery= {
/** Adds text written by this library (a keyword, an operator): never a value and never a name. */text(sql:string):Query;
/** Adds a parameter: its placeholder goes into the text, and the value into the parameters. */param(value:SqlValue):Query;
/** Adds the name of a table of the store (with its schema where there is one). */table(role:TableRole):Query;
/** Adds a name written as an identifier of the dialect. */name(name:string):Query;
/** Adds the bytes of an object as a value for a binary column. */bytes(value:Uint8Array):Query;
/** Adds the binary column as it is selected (of a table given by an alias where there is one), so that its bytes come back as bytes or as hex. */selectBytes(column:string, qualifier?:string):Query;
/** Adds ` FOR UPDATE` where the dialect locks a row that way. */forUpdate():Query;
done():Statement;
};