File tree 2 files changed +16
-6
lines changed 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -55,16 +55,15 @@ public final class SQLStatement {
55
55
56
56
/// Returns true (non-zero) if the statement has been stepped at least once
57
57
/// using `next()`, but has neither run to completion nor been reset.
58
- public var isBusy : Bool {
59
- sqlite3_stmt_busy ( ref) != 0
60
- }
58
+ public var isBusy : Bool { sqlite3_stmt_busy ( ref) != 0 }
61
59
62
60
/// Returns true if the statement makes no direct changes to the content of the database file.
63
61
///
64
62
/// - note: For more information see [documentation](https://www.sqlite.org/c3ref/stmt_readonly.html).
65
- public var isReadOnly : Bool {
66
- sqlite3_stmt_readonly ( ref) != 0
67
- }
63
+ public var isReadOnly : Bool { sqlite3_stmt_readonly ( ref) != 0 }
64
+
65
+ /// Returns the SQL text used to create the statement.
66
+ public var sql : String { String ( cString: sqlite3_sql ( ref) ) }
68
67
69
68
init ( db: SQLConnection , ref: OpaquePointer ) {
70
69
self . db = db
Original file line number Diff line number Diff line change @@ -251,6 +251,17 @@ final class SQLStatementTests: XCTestCase {
251
251
User ( name: " Bob " , level: 90 )
252
252
] )
253
253
}
254
+
255
+ // MARK: Misc
256
+
257
+ func testSQL( ) throws {
258
+ // GIVEN
259
+ try db. createTables ( )
260
+ let statement = try db. statement ( " SELECT * FROM Users " )
261
+
262
+ // THEN
263
+ XCTAssertEqual ( statement. sql, " SELECT * FROM Users " )
264
+ }
254
265
}
255
266
256
267
private extension SQLConnection {
You can’t perform that action at this time.
0 commit comments