mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-24 04:07:47 +00:00
Use rawSQL as parameter name for raw SQL
This commit is contained in:
1 parent
85f618e16e
commit
4bd5ace2ee
21 files changed
+200
-200
No files matched your search
@@ -9,7 +9,7 @@ extension SQLExpression {
|
||||
public var sqlLiteral: SQLLiteral {
|
||||
var context = SQLGenerationContext.literalGenerationContext(withArguments: true)
|
||||
let sql = expressionSQL(&context)
|
||||
return SQLLiteral(sql: sql, arguments: context.arguments!)
|
||||
return SQLLiteral(rawSQL: sql, arguments: context.arguments!)
|
||||
}
|
||||
|
||||
/// The expression as a quoted SQL literal (not public in order to avoid abuses)
|
||||
@@ -44,16 +44,16 @@ public struct SQLExpressionLiteral : SQLExpression {
|
||||
/// SQLExpressionLiteral(rawSQL: "? + ?", arguments: [1, 2])
|
||||
/// SQLExpressionLiteral(rawSQL: ":one + :two", arguments: ["one": 1, "two": 2])
|
||||
public init(rawSQL sql: String, arguments: StatementArguments = StatementArguments()) {
|
||||
self.init(literal: SQLLiteral(sql: sql, arguments: arguments))
|
||||
self.init(literal: SQLLiteral(rawSQL: sql, arguments: arguments))
|
||||
}
|
||||
|
||||
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
|
||||
///
|
||||
/// Creates an SQL literal expression.
|
||||
///
|
||||
/// SQLExpressionLiteral(literal: SQLLiteral(sql: "1 + 2")
|
||||
/// SQLExpressionLiteral(literal: SQLLiteral(sql: "? + ?", arguments: [1, 2]))
|
||||
/// SQLExpressionLiteral(literal: SQLLiteral(sql: ":one + :two", arguments: ["one": 1, "two": 2]))
|
||||
/// SQLExpressionLiteral(literal: SQLLiteral(rawSQL: "1 + 2")
|
||||
/// SQLExpressionLiteral(literal: SQLLiteral(rawSQL: "? + ?", arguments: [1, 2]))
|
||||
/// SQLExpressionLiteral(literal: SQLLiteral(rawSQL: ":one + :two", arguments: ["one": 1, "two": 2]))
|
||||
///
|
||||
/// With Swift 5, you can safely embed raw values in your SQL queries,
|
||||
/// without any risk of syntax errors or SQL injection:
|
||||
|
||||
Reference in new issue
Block a user