mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-24 04:07:47 +00:00
Cleanup
This commit is contained in:
1 parent
e351b79526
commit
bd9104d29f
2 files changed
+11
-10
No files matched your search
@@ -36,7 +36,7 @@ extension Database {
|
||||
/// - returns: A SelectStatement.
|
||||
/// - throws: A DatabaseError whenever SQLite could not parse the sql query.
|
||||
func makeSelectStatement(sql: String, prepFlags: Int32) throws -> SelectStatement {
|
||||
return try SelectStatement.prepare(sql: sql, prepFlags: prepFlags, in: self)
|
||||
return try SelectStatement.prepare(self, sql: sql, prepFlags: prepFlags)
|
||||
}
|
||||
|
||||
/// Returns a prepared statement that can be reused.
|
||||
@@ -85,7 +85,7 @@ extension Database {
|
||||
/// - returns: An UpdateStatement.
|
||||
/// - throws: A DatabaseError whenever SQLite could not parse the sql query.
|
||||
func makeUpdateStatement(sql: String, prepFlags: Int32) throws -> UpdateStatement {
|
||||
return try UpdateStatement.prepare(sql: sql, prepFlags: prepFlags, in: self)
|
||||
return try UpdateStatement.prepare(self, sql: sql, prepFlags: prepFlags)
|
||||
}
|
||||
|
||||
/// Returns a prepared statement that can be reused.
|
||||
|
||||
@@ -43,6 +43,7 @@ public class Statement {
|
||||
/// statement in the C string.
|
||||
/// - parameter prepFlags: Flags for sqlite3_prepare_v3 (available from
|
||||
/// SQLite 3.20.0, see http://www.sqlite.org/c3ref/prepare.html)
|
||||
/// - parameter authorizer: A StatementCompilationAuthorizer
|
||||
/// - throws: DatabaseError in case of compilation error.
|
||||
required init?(
|
||||
database: Database,
|
||||
@@ -227,14 +228,14 @@ public class Statement {
|
||||
extension Statement {
|
||||
// Static method instead of an initializer because initializer can't run
|
||||
// inside `sqlCodeUnits.withUnsafeBufferPointer`.
|
||||
static func prepare(sql: String, prepFlags: Int32, in database: Database) throws -> Self {
|
||||
static func prepare(_ db: Database, sql: String, prepFlags: Int32) throws -> Self {
|
||||
let authorizer = StatementCompilationAuthorizer()
|
||||
return try database.withAuthorizer(authorizer) {
|
||||
return try db.withAuthorizer(authorizer) {
|
||||
try sql.utf8CString.withUnsafeBufferPointer { buffer in
|
||||
let statementStart = buffer.baseAddress!
|
||||
var statementEnd: UnsafePointer<Int8>? = nil
|
||||
guard let statement = try self.init(
|
||||
database: database,
|
||||
database: db,
|
||||
statementStart: statementStart,
|
||||
statementEnd: &statementEnd,
|
||||
prepFlags: prepFlags,
|
||||
@@ -251,9 +252,9 @@ extension Statement {
|
||||
throw DatabaseError(
|
||||
resultCode: .SQLITE_MISUSE,
|
||||
message: """
|
||||
Multiple statements found. To execute multiple statements, \
|
||||
use Database.execute(sql:) instead.
|
||||
""",
|
||||
Multiple statements found. To execute multiple statements, \
|
||||
use Database.execute(sql:) instead.
|
||||
""",
|
||||
sql: sql)
|
||||
}
|
||||
|
||||
@@ -288,7 +289,7 @@ public final class SelectStatement: Statement {
|
||||
/// statement in the C string.
|
||||
/// - parameter prepFlags: Flags for sqlite3_prepare_v3 (available from
|
||||
/// SQLite 3.20.0, see http://www.sqlite.org/c3ref/prepare.html)
|
||||
/// - authorizer: A StatementCompilationAuthorizer
|
||||
/// - parameter authorizer: A StatementCompilationAuthorizer
|
||||
/// - throws: DatabaseError in case of compilation error.
|
||||
required init?(
|
||||
database: Database,
|
||||
@@ -451,7 +452,7 @@ public final class UpdateStatement: Statement {
|
||||
/// statement in the C string.
|
||||
/// - parameter prepFlags: Flags for sqlite3_prepare_v3 (available from
|
||||
/// SQLite 3.20.0, see http://www.sqlite.org/c3ref/prepare.html)
|
||||
/// - authorizer: A StatementCompilationAuthorizer
|
||||
/// - parameter authorizer: A StatementCompilationAuthorizer
|
||||
/// - throws: DatabaseError in case of compilation error.
|
||||
required init?(
|
||||
database: Database,
|
||||
|
||||
Reference in new issue
Block a user