File tree Expand file tree Collapse file tree 2 files changed +14
-15
lines changed Expand file tree Collapse file tree 2 files changed +14
-15
lines changed Original file line number Diff line number Diff line change @@ -152,21 +152,20 @@ public final class Connection {
152
152
Int ( sqlite3_total_changes ( handle) )
153
153
}
154
154
155
- /// Gets the user version of the database.
155
+ /// The user version of the database.
156
156
/// See SQLite [PRAGMA user_version](https://sqlite.org/pragma.html#pragma_user_version)
157
- /// - Returns: the user version of the database
158
- public func getUserVersion( ) throws -> Int32 ? {
159
- guard let userVersion = try scalar ( " PRAGMA user_version " ) as? Int64 else {
160
- return nil
157
+ public var userVersion : Int32 ? {
158
+ get {
159
+ guard let userVersion = try ? scalar ( " PRAGMA user_version " ) as? Int64 else {
160
+ return nil
161
+ }
162
+ return Int32 ( userVersion)
163
+ }
164
+ set {
165
+ if let userVersion = newValue {
166
+ _ = try ? run ( " PRAGMA user_version = \( userVersion) " )
167
+ }
161
168
}
162
- return Int32 ( userVersion)
163
- }
164
-
165
- /// Sets the user version of the database.
166
- /// See SQLite [PRAGMA user_version](https://sqlite.org/pragma.html#pragma_user_version)
167
- /// - Parameter userVersion: the new user version of the database
168
- public func setUserVersion( to userVersion: Int32 ) throws {
169
- try run ( " PRAGMA user_version = \( userVersion) " )
170
169
}
171
170
172
171
// MARK: - Execute
Original file line number Diff line number Diff line change @@ -97,8 +97,8 @@ class ConnectionTests: SQLiteTestCase {
97
97
}
98
98
99
99
func test_userVersion( ) {
100
- try ! db. setUserVersion ( to : 2 )
101
- XCTAssertEqual ( 2 , try ! db. getUserVersion ( ) !)
100
+ db. userVersion = 2
101
+ XCTAssertEqual ( 2 , db. userVersion !)
102
102
}
103
103
104
104
func test_prepare_preparesAndReturnsStatements( ) {
You can’t perform that action at this time.
0 commit comments