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 {
152152 Int ( sqlite3_total_changes ( handle) )
153153 }
154154
155- /// Gets the user version of the database.
155+ /// The user version of the database.
156156 /// 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+ }
161168 }
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) " )
170169 }
171170
172171 // MARK: - Execute
Original file line number Diff line number Diff line change @@ -97,8 +97,8 @@ class ConnectionTests: SQLiteTestCase {
9797 }
9898
9999 func test_userVersion( ) {
100- try ! db. setUserVersion ( to : 2 )
101- XCTAssertEqual ( 2 , try ! db. getUserVersion ( ) !)
100+ db. userVersion = 2
101+ XCTAssertEqual ( 2 , db. userVersion !)
102102 }
103103
104104 func test_prepare_preparesAndReturnsStatements( ) {
You can’t perform that action at this time.
0 commit comments