mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-29 04:24:21 +00:00
Update documentation for literal interpolation
This commit is contained in:
1 parent
f15b2e12d6
commit
354d22d70d
10 files changed
+39
-39
No files matched your search
@@ -133,7 +133,7 @@ extension QueryInterfaceRequest : DerivableRequest, AggregatingRequest {
|
||||
/// let request = Player.
|
||||
/// .filter(primaryKey: 42)
|
||||
/// .select(
|
||||
/// SQLLiteral("IFNULL(name, \("Anonymous"))"),
|
||||
/// literal: "IFNULL(name, \("Anonymous"))",
|
||||
/// as: String.self)
|
||||
/// let name: String? = try request.fetchOne(db)
|
||||
/// }
|
||||
@@ -378,7 +378,7 @@ extension TableRecord {
|
||||
/// Creates a request which selects *sql*.
|
||||
///
|
||||
/// // SELECT id, email FROM player
|
||||
/// let request = Player.select(literal: SQLLiteral("id, email"))
|
||||
/// let request = Player.select(literal: SQLLiteral(sql: "id, email"))
|
||||
public static func select(literal sqlLiteral: SQLLiteral) -> QueryInterfaceRequest<Self> {
|
||||
return all().select(literal: sqlLiteral)
|
||||
}
|
||||
@@ -424,7 +424,7 @@ extension TableRecord {
|
||||
///
|
||||
/// try dbQueue.read { db in
|
||||
/// // SELECT max(score) FROM player
|
||||
/// let request = Player.select(literal: SQLLiteral("max(score)"), as: Int.self)
|
||||
/// let request = Player.select(literal: SQLLiteral(sql: "max(score)"), as: Int.self)
|
||||
/// let maxScore: Int? = try request.fetchOne(db)
|
||||
/// }
|
||||
public static func select<RowDecoder>(literal sqlLiteral: SQLLiteral, as type: RowDecoder.Type) -> QueryInterfaceRequest<RowDecoder> {
|
||||
@@ -517,7 +517,7 @@ extension TableRecord {
|
||||
/// With Swift 5, you can safely embed raw values in your SQL queries,
|
||||
/// without any risk of syntax errors or SQL injection:
|
||||
///
|
||||
/// let request = Player.filter(literal: SQLLiteral("email = \("arthur@example.com")))
|
||||
/// let request = Player.filter(literal: "email = \("arthur@example.com"))
|
||||
///
|
||||
/// The selection defaults to all columns. This default can be changed for
|
||||
/// all requests by the `TableRecord.databaseSelection` property, or
|
||||
|
||||
@@ -70,7 +70,7 @@ extension SelectionRequest {
|
||||
/// // SELECT id, email, score + 1000 FROM player
|
||||
/// let bonus = 1000
|
||||
/// var request = Player.all()
|
||||
/// request = request.select(literal: SQLLiteral("""
|
||||
/// request = request.select(literal: """
|
||||
/// id, email, score + \(bonus)
|
||||
/// """)
|
||||
///
|
||||
@@ -139,7 +139,7 @@ extension FilteredRequest {
|
||||
///
|
||||
/// // SELECT * FROM player WHERE email = 'arthur@example.com'
|
||||
/// var request = Player.all()
|
||||
/// request = request.filter(literal: SQLLiteral("""
|
||||
/// request = request.filter(literal: """
|
||||
/// email = \("arthur@example.com")
|
||||
/// """)
|
||||
public func filter(literal sqlLiteral: SQLLiteral) -> Self {
|
||||
|
||||
@@ -65,7 +65,7 @@ public struct SQLExpressionLiteral : SQLExpression {
|
||||
/// With Swift 5, you can safely embed raw values in your SQL queries,
|
||||
/// without any risk of syntax errors or SQL injection:
|
||||
///
|
||||
/// SQLExpressionLiteral(literal: SQLLiteral("\(1) + \(2)"))
|
||||
/// SQLExpressionLiteral(literal: "\(1) + \(2)")
|
||||
public init(literal sqlLiteral: SQLLiteral) {
|
||||
self.sqlLiteral = sqlLiteral
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user