Add additional interpolations, constructors, and operations to SQLQueryString
This patch was authored and released by @gwynne.
Several new capabilities are available on SQLQueryString
, as used by SQLRawBuilder
:
- Integer literal interpolation, e.g.
\(literal: 1)
, for rendering correctly escaped numeric literals according to the database'sSQLDialect
- Boolean literal interpolation, e.g.
\(literal: true)
, for rendering correctly escaped boolean literals according to the database'sSQLDialect
- String literal interpolation, e.g.
\(literal: "hello")
, for rendering strings as correctly escaped literal values in the database'sSQLDialect
- Arrays of string literals interpolation, e.g.
\(literals: ["hello", "world", "how", "are", "you"], joinedBy: " ")
- SQL identifier interpolation, e.g.
\(ident: "created_at")
, for rendering names as correctly escaped identifiers according to the database'sSQLDialect
- identifiers are usually table names, column names, alias names for tables and columns, and other similar items. PostgreSQL and SQLite enclose identifiers in"
characters; MySQL uses backticks. - Arrays of SQL identifiers interpolation, e.g.
\(idents: ["id", "created_at", "updated_at"], joinedBy: ", ")
- great for generating column name lists forINSERT
, for example. - A
+
operator for concatenating twoSQLQueryString
s. Credit for this functionality goes to @t-ae in #111. Array<SQLQueryString>.joined(separator:)
, similar toArray<String>.joined(separator:)
. Credit for this functionality goes to @t-ae in #111.- Improved tests for
SQLQueryString
. Partial credit for the improvements goes to @t-ae in #111.