You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Semver version strings do not sort well lexicographically. In #2100 I hacked in DB sorting of system updates by version by adding a second column to sort by, version_sort:
-- The version of the system update this component's software came from.
-- This may need to be nullable if we are registering components before we
-- know about system versions at all
system_version STRING(64) NOT NULL, -- TODO: length
-- version string with maj/min/patch 0-padded to be string sortable
system_version_sort STRING(64) NOT NULL, -- TODO: length
which uses left zero padding to make the versions sort almost correctly. (Technically, build and prerelease meta are not supposed to be sorted lexicographically, but we have decided to tolerate being wrong in this way for now.)
However! These do not actually need to be two columns. I only did it that way because I didn't feel like figuring out how to deserialize the zero-padded version string back into a Semver::Version (built-in parse chokes on the zeros). The change that's required here is to update our ToSql for SemverVersion to do the zero-padding and the FromSql to remove the zero-padding before passing it to Semver::Version's parse.
Closes#2344. Followup to #2100. Rather than manually adding a sortable
`version_sort` column alongside the `version` column, make
`SemverVersion` itself automatically sortable by serializing it to the
DB in sortable form (with zero padding on the numbers). On
deserialization, we remove the padding before trying to parse it.
Semver version strings do not sort well lexicographically. In #2100 I hacked in DB sorting of system updates by version by adding a second column to sort by,
version_sort
:omicron/common/src/sql/dbinit.sql
Lines 1575 to 1578 in 46f2295
omicron/common/src/sql/dbinit.sql
Lines 1667 to 1672 in 46f2295
which uses left zero padding to make the versions sort almost correctly. (Technically, build and prerelease meta are not supposed to be sorted lexicographically, but we have decided to tolerate being wrong in this way for now.)
omicron/nexus/db-model/src/semver_version.rs
Lines 59 to 73 in 46f2295
However! These do not actually need to be two columns. I only did it that way because I didn't feel like figuring out how to deserialize the zero-padded version string back into a
Semver::Version
(built-inparse
chokes on the zeros). The change that's required here is to update ourToSql
forSemverVersion
to do the zero-padding and theFromSql
to remove the zero-padding before passing it toSemver::Version
'sparse
.omicron/nexus/db-model/src/semver_version.rs
Lines 86 to 110 in 46f2295
That way, we do not have to generate a sortable string manually in the constructor.
omicron/nexus/db-model/src/system_update.rs
Lines 42 to 54 in 46f2295
The text was updated successfully, but these errors were encountered: