-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Native user_version support in Connection #1105
Conversation
@jberkel Test fails on Linux because of something related to encodable, but I don't think that it is related to my changes. Do you have any idea?
|
@nathanfallet the test is brittle because it compares the JSON as a string. On Linux the JSON serialization is different (order of fields). You could make the JSON serialization more deterministic with |
@jberkel Right, I'm gonna inspect that. I need to understand why it changed since the last commit (because test was passing for the last commit on master) |
Sources/SQLite/Core/Connection.swift
Outdated
/// Gets the user version of the database. | ||
/// See SQLite [PRAGMA user_version](https://sqlite.org/pragma.html#pragma_user_version) | ||
/// - Returns: the user version of the database | ||
public func getUserVersion() throws -> Int32? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var userVersion: Int32? {
get { }
set { }
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that first, but I ended with problems with try
. I can eventually ignore them with optionals
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think it's ok to ignore the error here
After inspection, it means that |
Possibly, there are no guarantees by the method. I think we should do both: make the JSON output consistent (with |
Sources/SQLite/Core/Connection.swift
Outdated
return nil | ||
public var userVersion: Int32? { | ||
get { | ||
guard let userVersion = try? scalar("PRAGMA user_version") as? Int64 else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(try? scalar("PRAGMA user_version") as? Int64).map(Int32.init)
No description provided.