SQLLiteral
public struct SQLLiteral
SQLLiteral is a type which support SQL Interpolation.
For example:
try dbQueue.write { db in
let name: String = ...
let id: Int64 = ...
let query: SQLLiteral = "UPDATE player SET name = \(name) WHERE id = \(id)"
try db.execute(literal: query)
}
-
Undocumented
Declaration
Swift
public private(set) var sql: String
-
Undocumented
Declaration
Swift
public private(set) var arguments: StatementArguments
-
Creates an SQLLiteral from a plain SQL string, and eventual arguments.
For example:
let query = SQLLiteral( sql: "UPDATE player SET name = ? WHERE id = ?", arguments: [name, id])
Declaration
Swift
public init(sql: String, arguments: StatementArguments = StatementArguments())
-
Returns a literal whose SQL is transformed by the given closure.
Declaration
Swift
public func mapSQL(_ transform: (String) throws -> String) rethrows -> SQLLiteral
-
Returns the SQLLiteral produced by the concatenation of two literals.
let name = "O'Brien" let selection: SQLLiteral = "SELECT * FROM player " let condition: SQLLiteral = "WHERE name = \(name)" let query = selection + condition
Declaration
Swift
public static func + (lhs: SQLLiteral, rhs: SQLLiteral) -> SQLLiteral
-
Appends an SQLLiteral to the receiver.
let name = "O'Brien" var query: SQLLiteral = "SELECT * FROM player " query += "WHERE name = \(name)"
Declaration
Swift
public static func += (lhs: inout SQLLiteral, rhs: SQLLiteral)
-
Appends an SQLLiteral to the receiver.
let name = "O'Brien" var query: SQLLiteral = "SELECT * FROM player " query.append(literal: "WHERE name = \(name)")
Declaration
Swift
public mutating func append(literal sqlLiteral: SQLLiteral)
-
Appends a plain SQL string to the receiver, and eventual arguments.
let name = "O'Brien" var query: SQLLiteral = "SELECT * FROM player " query.append(sql: "WHERE name = ?", arguments: [name])
Declaration
Swift
public mutating func append(sql: String, arguments: StatementArguments = StatementArguments())