Skip to content
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

Merge version and version_sort #2346

Merged
merged 1 commit into from
Feb 10, 2023
Merged

Merge version and version_sort #2346

merged 1 commit into from
Feb 10, 2023

Conversation

david-crespo
Copy link
Contributor

@david-crespo david-crespo commented Feb 10, 2023

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.

@zephraph
Copy link
Contributor

Cool, yeah. I much prefer only having one column representing the version.

version STRING(64) NOT NULL, -- TODO: length
-- version string with maj/min/patch 0-padded to be string sortable
version_sort STRING(64) NOT NULL -- TODO: length
version STRING(64) NOT NULL -- TODO: length
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One random thing here... I noticed a lot of other strings are defined as 63 characters in the DB and I'm not exactly sure why that is.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like CRDB itself imposes that length limit on some of its internal strings: https://www.cockroachlabs.com/docs/stable/schema-design-overview.html#hard-limits

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, there's a comment at the top but it is ambivalent about 63 or 64.

* Important CockroachDB notes:
*
* The syntax STRING(63) means a Unicode string with at most 63 code points,
* not 63 bytes. In many cases, Nexus itself will validate a string's
* byte count or code points, so it's still reasonable to limit ourselves to
* powers of two (or powers-of-two-minus-one) to improve storage utilization.

@david-crespo david-crespo merged commit 98949c9 into main Feb 10, 2023
@david-crespo david-crespo deleted the sortable-version branch February 10, 2023 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Merge version and version_sort columns
2 participants