Update documentation for literal interpolation

This commit is contained in:
Gwendal Roué committed 2019-02-17 13:24:38 +01:00
1 parent f15b2e12d6
commit 354d22d70d
10 files changed
+39 -39

No files matched your search

+2 -2
View File
@@ -145,11 +145,11 @@ extension Database {
/// With Swift 5, you can safely embed raw values in your SQL queries,
/// without any risk of syntax errors or SQL injection:
///
/// try db.execute(literal: SQLLiteral("""
/// try db.execute(literal: """
/// INSERT INTO player (name) VALUES (\("Arthur"));
/// INSERT INTO player (name) VALUES (\("Barbara"));
/// INSERT INTO player (name) VALUES (\("O'Brien"));
/// """))
/// """)
///
/// This method may throw a DatabaseError.
///
+10 -10
View File
@@ -315,10 +315,10 @@ extension DatabaseValueConvertible {
/// With Swift 5, you can safely embed raw values in your SQL queries,
/// without any risk of syntax errors or SQL injection:
///
/// let firstNames = try String.fetchCursor(db, literal: SQLLiteral("""
/// let firstNames = try String.fetchCursor(db, literal: """
/// SELECT firstName FROM player
/// WHERE lastName = \("O'Brien")
/// """)) // Cursor of String
/// """) // Cursor of String
///
/// If the database is modified during the cursor iteration, the remaining
/// elements are undefined.
@@ -348,10 +348,10 @@ extension DatabaseValueConvertible {
/// With Swift 5, you can safely embed raw values in your SQL queries,
/// without any risk of syntax errors or SQL injection:
///
/// let firstNames = try String.fetchAll(db, literal: SQLLiteral("""
/// let firstNames = try String.fetchAll(db, literal: """
/// SELECT firstName FROM player
/// WHERE lastName = \("O'Brien")
/// """)) // [String]
/// """) // [String]
///
/// - parameters:
/// - db: A database connection.
@@ -376,10 +376,10 @@ extension DatabaseValueConvertible {
/// With Swift 5, you can safely embed raw values in your SQL queries,
/// without any risk of syntax errors or SQL injection:
///
/// let firstName = try String.fetchOne(db, literal: SQLLiteral("""
/// let firstName = try String.fetchOne(db, literal: """
/// SELECT firstName FROM player
/// WHERE lastName = \("O'Brien")
/// """)) // String?
/// """) // String?
///
/// - parameters:
/// - db: A database connection.
@@ -621,10 +621,10 @@ extension Optional where Wrapped: DatabaseValueConvertible {
/// With Swift 5, you can safely embed raw values in your SQL queries,
/// without any risk of syntax errors or SQL injection:
///
/// let firstNames = try Optional<String>.fetchCursor(db, literal: SQLLiteral("""
/// let firstNames = try Optional<String>.fetchCursor(db, literal: """
/// SELECT firstName FROM player
/// WHERE lastName = \("O'Brien")
/// """)) // Cursor of String?
/// """) // Cursor of String?
///
/// If the database is modified during the cursor iteration, the remaining
/// elements are undefined.
@@ -654,10 +654,10 @@ extension Optional where Wrapped: DatabaseValueConvertible {
/// With Swift 5, you can safely embed raw values in your SQL queries,
/// without any risk of syntax errors or SQL injection:
///
/// let firstNames = try Optional<String>.fetchAll(db, literal: SQLLiteral("""
/// let firstNames = try Optional<String>.fetchAll(db, literal: """
/// SELECT firstName FROM player
/// WHERE lastName = \("O'Brien")
/// """)) // [String?]
/// """) // [String?]
///
/// - parameters:
/// - db: A database connection.
+3 -3
View File
@@ -812,7 +812,7 @@ extension Row {
/// With Swift 5, you can safely embed raw values in your SQL queries,
/// without any risk of syntax errors or SQL injection:
///
/// let rows = try Row.fetchCursor(db, literal: SQLLiteral("""
/// let rows = try Row.fetchCursor(db, literal: """
/// SELECT * FROM player WHERE lastName = \("O'Brien")
/// """) // RowCursor
///
@@ -853,7 +853,7 @@ extension Row {
/// With Swift 5, you can safely embed raw values in your SQL queries,
/// without any risk of syntax errors or SQL injection:
///
/// let rows = try Row.fetchAll(db, literal: SQLLiteral("""
/// let rows = try Row.fetchAll(db, literal: """
/// SELECT * FROM player WHERE lastName = \("O'Brien")
/// """) // [Row]
///
@@ -881,7 +881,7 @@ extension Row {
/// With Swift 5, you can safely embed raw values in your SQL queries,
/// without any risk of syntax errors or SQL injection:
///
/// let row = try Row.fetchOne(db, literal: SQLLiteral("""
/// let row = try Row.fetchOne(db, literal: """
/// SELECT * FROM player WHERE lastName = \("O'Brien")
/// """) // Row?
///
+2 -2
View File
@@ -43,9 +43,9 @@ public struct SQLRequest<T> : FetchRequest {
/// With Swift 5, you can safely embed raw values in your SQL queries,
/// without any risk of syntax errors or SQL injection:
///
/// let request = SQLRequest<Player>(literal: SQLLiteral("""
/// let request = SQLRequest<Player>(literal: """
/// SELECT * FROM player WHERE name = \("O'brien")
/// """))
/// """)
///
/// - parameters:
/// - sqlLiteral: An SQLLiteral.
+10 -10
View File
@@ -300,10 +300,10 @@ extension DatabaseValueConvertible where Self: StatementColumnConvertible {
/// With Swift 5, you can safely embed raw values in your SQL queries,
/// without any risk of syntax errors or SQL injection:
///
/// let firstNames = try String.fetchCursor(db, literal: SQLLiteral("""
/// let firstNames = try String.fetchCursor(db, literal: """
/// SELECT firstName FROM player
/// WHERE lastName = \("O'Brien")
/// """)) // Cursor of String
/// """) // Cursor of String
///
/// If the database is modified during the cursor iteration, the remaining
/// elements are undefined.
@@ -333,10 +333,10 @@ extension DatabaseValueConvertible where Self: StatementColumnConvertible {
/// With Swift 5, you can safely embed raw values in your SQL queries,
/// without any risk of syntax errors or SQL injection:
///
/// let firstNames = try String.fetchAll(db, literal: SQLLiteral("""
/// let firstNames = try String.fetchAll(db, literal: """
/// SELECT firstName FROM player
/// WHERE lastName = \("O'Brien")
/// """)) // [String]
/// """) // [String]
///
/// - parameters:
/// - db: A database connection.
@@ -361,10 +361,10 @@ extension DatabaseValueConvertible where Self: StatementColumnConvertible {
/// With Swift 5, you can safely embed raw values in your SQL queries,
/// without any risk of syntax errors or SQL injection:
///
/// let firstName = try String.fetchOne(db, literal: SQLLiteral("""
/// let firstName = try String.fetchOne(db, literal: """
/// SELECT firstName FROM player
/// WHERE lastName = \("O'Brien")
/// """)) // String?
/// """) // String?
///
/// - parameters:
/// - db: A database connection.
@@ -602,10 +602,10 @@ extension Optional where Wrapped: DatabaseValueConvertible & StatementColumnConv
/// With Swift 5, you can safely embed raw values in your SQL queries,
/// without any risk of syntax errors or SQL injection:
///
/// let firstNames = try Optional<String>.fetchCursor(db, literal: SQLLiteral("""
/// let firstNames = try Optional<String>.fetchCursor(db, literal: """
/// SELECT firstName FROM player
/// WHERE lastName = \("O'Brien")
/// """)) // Cursor of String?
/// """) // Cursor of String?
///
/// If the database is modified during the cursor iteration, the remaining
/// elements are undefined.
@@ -635,10 +635,10 @@ extension Optional where Wrapped: DatabaseValueConvertible & StatementColumnConv
/// With Swift 5, you can safely embed raw values in your SQL queries,
/// without any risk of syntax errors or SQL injection:
///
/// let firstNames = try Optional<String>.fetchAll(db, literal: SQLLiteral("""
/// let firstNames = try Optional<String>.fetchAll(db, literal: """
/// SELECT firstName FROM player
/// WHERE lastName = \("O'Brien")
/// """)) // [String?]
/// """) // [String?]
///
/// - parameters:
/// - db: A database connection.
@@ -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
+2 -2
View File
@@ -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
}
+3 -3
View File
@@ -270,7 +270,7 @@ extension FetchableRecord {
/// With Swift 5, you can safely embed raw values in your SQL queries,
/// without any risk of syntax errors or SQL injection:
///
/// let players = try Player.fetchCursor(db, literal: SQLLiteral("""
/// let players = try Player.fetchCursor(db, literal: """
/// SELECT * FROM player WHERE lastName = \("O'Brien")
/// """) // Cursor of Player
///
@@ -301,7 +301,7 @@ extension FetchableRecord {
/// With Swift 5, you can safely embed raw values in your SQL queries,
/// without any risk of syntax errors or SQL injection:
///
/// let players = try Player.fetchAll(db, literal: SQLLiteral("""
/// let players = try Player.fetchAll(db, literal: """
/// SELECT * FROM player WHERE lastName = \("O'Brien")
/// """) // [Player]
///
@@ -327,7 +327,7 @@ extension FetchableRecord {
/// With Swift 5, you can safely embed raw values in your SQL queries,
/// without any risk of syntax errors or SQL injection:
///
/// let player = try Player.fetchOne(db, literal: SQLLiteral("""
/// let player = try Player.fetchOne(db, literal: """
/// SELECT * FROM player WHERE lastName = \("O'Brien")
/// """) // Player?
///
@@ -365,9 +365,9 @@ try dbQueue.read { db in
//: without any risk of syntax errors or SQL injection:
//:
//: try dbQueue.read { db in
//: try Base.fetchAll(db, literal: SQLLiteral("""
//: try Base.fetchAll(db, literal: """
//: SELECT ... WHERE name = \("O'Brien")
//: """)) // [Base]
//: """) // [Base]
//: }
extension MyDatabaseDecoder {
// MARK: - Fetch from SQLLiteral