-
Notifications
You must be signed in to change notification settings - Fork 33
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
Comparable version representation #109
base: master
Are you sure you want to change the base?
Conversation
Comparable strings adds support for external databases, where we want compare versions by native comparsion of the database.
@stapelberg mind doing a review? This is changing quite a bit, and you wrote this code originally. |
@@ -199,6 +397,9 @@ func parseInto(result *Version, input string) error { | |||
} | |||
|
|||
colon := strings.Index(trimmed, ":") | |||
if (colon >= 9) { | |||
return fmt.Errorf("epoch too big or not an integer") |
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.
The epoch can be any unsigned integer; a valid version can be 10000000000:1.0-1
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.
Such epoch is valid, but not supported. It does not fit into 32bit integer, so most parsers would have problems (comparing it) anyways.
This also may not help you, but there's a
|
Indeed, I was using this with some old version MySQL server. Having precomputed value for comparisons can be beneficial also for other uses (e.g., when sorting large number of versions, because byte-string comparison is much faster than interpreting debian version for every comparison.). |
The PostgreSQL version here is index-able and is quite fast - we use it in production for the entire Debian archive 👍 |
The more I think about this changeset, the more that I think this could be a separate package that takes a |
I'm OK with the decision that it should be separate package. I wrote this code so maybe I should take responsibility for it in my own repository. |
Ascii representations of debian versions can be comparend using simple ASCII dictionary ordering to get result of comparison of original version. Intended usage is to store ASCII representation in separate column in SQL table of packages and then use ORDER BY to obtain the package with the highest version.