SQLExpressionLiteral

public struct SQLExpressionLiteral : SQLExpression

Experimental

SQLExpressionLiteral is an expression built from a raw SQL snippet.

SQLExpressionLiteral(sql: "1 + 2")

The SQL literal may contain ? and colon-prefixed arguments:

SQLExpressionLiteral(sql: "? + ?", arguments: [1, 2])
SQLExpressionLiteral(sql: ":one + :two", arguments: ["one": 1, "two": 2])
  • sql

    Undocumented

    Declaration

    Swift

    public var sql: String { get }
  • Undocumented

    Declaration

    Swift

    public var arguments: StatementArguments { get }
  • Experimental

    Creates an SQL literal expression.

    SQLExpressionLiteral(sql: "1 + 2")
    SQLExpressionLiteral(sql: "? + ?", arguments: [1, 2])
    SQLExpressionLiteral(sql: ":one + :two", arguments: ["one": 1, "two": 2])
    

    Declaration

    Swift

    public init(sql: String, arguments: StatementArguments = StatementArguments())
  • Experimental

    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]))
    

    With Swift 5, you can safely embed raw values in your SQL queries, without any risk of syntax errors or SQL injection:

    SQLExpressionLiteral(literal: "\(1) + \(2)")
    

    Declaration

    Swift

    public init(literal sqlLiteral: SQLLiteral)