mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-30 04:28:44 +00:00
Merge pull request #967 from steipete/peter/selectStatement-Debug
Make SelectStatement conform to CustomStringConvertible
This commit is contained in:
2 files changed
+9
-2
No files matched your search
@@ -19,6 +19,8 @@ public class Statement {
|
||||
|
||||
/// The SQL query
|
||||
public var sql: String {
|
||||
SchedulingWatchdog.preconditionValidQueue(database)
|
||||
|
||||
// trim white space and semicolumn for homogeneous output
|
||||
return String(cString: sqlite3_sql(sqliteStatement))
|
||||
.trimmingCharacters(in: .sqlStatementSeparators)
|
||||
@@ -262,6 +264,12 @@ public class Statement {
|
||||
}
|
||||
}
|
||||
|
||||
extension Statement: CustomStringConvertible {
|
||||
public var description: String {
|
||||
"SQL: \(sql), Arguments: \(arguments)"
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Statement Preparation
|
||||
|
||||
extension Statement {
|
||||
|
||||
@@ -7841,8 +7841,7 @@ You can compile the request into a prepared statement:
|
||||
try dbQueue.read { db in
|
||||
let request = Player.filter(Column("name") == "O'Brien")
|
||||
let statement = try request.makePreparedRequest(db).statement
|
||||
print(statement.sql) // "SELECT * FROM player WHERE name = ?"
|
||||
print(statement.arguments) // ["O'Brien"]
|
||||
print(statement) // SQL: SELECT * FROM player WHERE name = ?, Arguments: ["O'Brien"]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in new issue
Block a user