From ff439c2dbcd68501cda61f9168bd047e8a1eb560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sun, 10 Feb 2019 18:45:07 +0100 Subject: [PATCH] Documentation --- GRDB/Core/Database+Statements.swift | 7 ++----- GRDB/Core/DatabaseValueConvertible.swift | 15 ++++++++++----- GRDB/Core/Row.swift | 9 ++++++--- GRDB/Core/SQLRequest.swift | 3 ++- GRDB/Core/StatementColumnConvertible.swift | 15 ++++++++++----- GRDB/Record/FetchableRecord.swift | 9 ++++++--- .../Contents.swift | 3 ++- 7 files changed, 38 insertions(+), 23 deletions(-) diff --git a/GRDB/Core/Database+Statements.swift b/GRDB/Core/Database+Statements.swift index 5ce42a8ce..05edbc49d 100644 --- a/GRDB/Core/Database+Statements.swift +++ b/GRDB/Core/Database+Statements.swift @@ -205,11 +205,8 @@ extension Database { /// INSERT INTO player (name) VALUES (?); /// """, arguments: ["Arthur", "Barbara", "O'Brien"])) /// - /// With Swift 5, you can profit from string interpolation: - /// - /// try db.execute(SQLString(""" - /// INSERT INTO player (name) VALUES (\("Arthur")) - /// """)) + /// 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(SQLString(""" /// INSERT INTO player (name) VALUES (\("Arthur")); diff --git a/GRDB/Core/DatabaseValueConvertible.swift b/GRDB/Core/DatabaseValueConvertible.swift index 627dce99a..18ecac519 100644 --- a/GRDB/Core/DatabaseValueConvertible.swift +++ b/GRDB/Core/DatabaseValueConvertible.swift @@ -315,7 +315,8 @@ extension DatabaseValueConvertible { /// ... /// } /// - /// With Swift 5, you can profit from string interpolation: + /// 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, SQLString(""" /// SELECT firstName FROM player @@ -347,7 +348,8 @@ extension DatabaseValueConvertible { /// ... /// } /// - /// With Swift 5, you can profit from string interpolation: + /// 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, SQLString(""" /// SELECT firstName FROM player @@ -374,7 +376,8 @@ extension DatabaseValueConvertible { /// WHERE lastName = ? /// """, arguments: ["O'Brien"])) // String? /// - /// With Swift 5, you can profit from string interpolation: + /// 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, SQLString(""" /// SELECT firstName FROM player @@ -620,7 +623,8 @@ extension Optional where Wrapped: DatabaseValueConvertible { /// ... /// } /// - /// With Swift 5, you can profit from string interpolation: + /// 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.fetchCursor(db, SQLString(""" /// SELECT firstName FROM player @@ -652,7 +656,8 @@ extension Optional where Wrapped: DatabaseValueConvertible { /// ... /// } /// - /// With Swift 5, you can profit from string interpolation: + /// 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.fetchAll(db, SQLString(""" /// SELECT firstName FROM player diff --git a/GRDB/Core/Row.swift b/GRDB/Core/Row.swift index e679c3eba..60e353dbe 100644 --- a/GRDB/Core/Row.swift +++ b/GRDB/Core/Row.swift @@ -812,7 +812,8 @@ extension Row { /// let lastName: String = row["lastName"] /// } /// - /// With Swift 5, you can profit from string interpolation: + /// 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, SQLString(""" /// SELECT * FROM player WHERE lastName = \("O'Brien") @@ -852,7 +853,8 @@ extension Row { /// let lastName: String = row["lastName"] /// } /// - /// With Swift 5, you can profit from string interpolation: + /// 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, SQLString(""" /// SELECT * FROM player WHERE lastName = \("O'Brien") @@ -879,7 +881,8 @@ extension Row { /// let lastName: String = row["lastName"] /// } /// - /// With Swift 5, you can profit from string interpolation: + /// 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, SQLString(""" /// SELECT * FROM player WHERE lastName = \("O'Brien") diff --git a/GRDB/Core/SQLRequest.swift b/GRDB/Core/SQLRequest.swift index 7d1045594..f4b2f2dd5 100644 --- a/GRDB/Core/SQLRequest.swift +++ b/GRDB/Core/SQLRequest.swift @@ -39,7 +39,8 @@ public struct SQLRequest : FetchRequest { /// SELECT * FROM player WHERE name = ? /// """, arguments: ["O'Brien"])) /// - /// With Swift 5, you can profit from string interpolation: + /// 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(SQLString(""" /// SELECT * FROM player WHERE name = \("O'brien") diff --git a/GRDB/Core/StatementColumnConvertible.swift b/GRDB/Core/StatementColumnConvertible.swift index c647a2c85..91a588f55 100644 --- a/GRDB/Core/StatementColumnConvertible.swift +++ b/GRDB/Core/StatementColumnConvertible.swift @@ -300,7 +300,8 @@ extension DatabaseValueConvertible where Self: StatementColumnConvertible { /// ... /// } /// - /// With Swift 5, you can profit from string interpolation: + /// 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, SQLString(""" /// SELECT firstName FROM player @@ -332,7 +333,8 @@ extension DatabaseValueConvertible where Self: StatementColumnConvertible { /// ... /// } /// - /// With Swift 5, you can profit from string interpolation: + /// 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, SQLString(""" /// SELECT firstName FROM player @@ -359,7 +361,8 @@ extension DatabaseValueConvertible where Self: StatementColumnConvertible { /// WHERE lastName = ? /// """, arguments: ["O'Brien"])) // String? /// - /// With Swift 5, you can profit from string interpolation: + /// 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, SQLString(""" /// SELECT firstName FROM player @@ -601,7 +604,8 @@ extension Optional where Wrapped: DatabaseValueConvertible & StatementColumnConv /// ... /// } /// - /// With Swift 5, you can profit from string interpolation: + /// 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.fetchCursor(db, SQLString(""" /// SELECT firstName FROM player @@ -633,7 +637,8 @@ extension Optional where Wrapped: DatabaseValueConvertible & StatementColumnConv /// ... /// } /// - /// With Swift 5, you can profit from string interpolation: + /// 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.fetchAll(db, SQLString(""" /// SELECT firstName FROM player diff --git a/GRDB/Record/FetchableRecord.swift b/GRDB/Record/FetchableRecord.swift index 430bf9c5d..6ef991eb5 100644 --- a/GRDB/Record/FetchableRecord.swift +++ b/GRDB/Record/FetchableRecord.swift @@ -270,7 +270,8 @@ extension FetchableRecord { /// ... /// } /// - /// With Swift 5, you can profit from string interpolation: + /// 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, SQLString(""" /// SELECT * FROM player WHERE lastName = \("O'Brien") @@ -300,7 +301,8 @@ extension FetchableRecord { /// ... /// } /// - /// With Swift 5, you can profit from string interpolation: + /// 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, SQLString(""" /// SELECT * FROM player WHERE lastName = \("O'Brien") @@ -325,7 +327,8 @@ extension FetchableRecord { /// ... /// } /// - /// With Swift 5, you can profit from string interpolation: + /// 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, SQLString(""" /// SELECT * FROM player WHERE lastName = \("O'Brien") diff --git a/Playgrounds/CustomizedDecodingOfDatabaseRows.playground/Contents.swift b/Playgrounds/CustomizedDecodingOfDatabaseRows.playground/Contents.swift index ecb1a1764..b8b328de7 100644 --- a/Playgrounds/CustomizedDecodingOfDatabaseRows.playground/Contents.swift +++ b/Playgrounds/CustomizedDecodingOfDatabaseRows.playground/Contents.swift @@ -361,7 +361,8 @@ try dbQueue.read { db in //: """, arguments: ["O'Brien"]) // [Base] //: } //: -//: With Swift 5, you can profit from string interpolation: +//: With Swift 5, you can safely embed raw values in your SQL queries, +//: without any risk of syntax errors or SQL injection: //: //: try dbQueue.read { db in //: try Base.fetchAll(db, SQLString("""