-
Notifications
You must be signed in to change notification settings - Fork 24
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
Incorrect handling of non-numeric prerelease identifiers with leading zeroes #45
Comments
Relatedly I'm not sure whether |
Please see my comment on this in #38. In addition: Valid: Not valid: Note that there is no provision in the spec for hex values in prerelease numeric fields. Because metadata is not included in the precedence order, their are no restrictions other than the allowed subset of ASCII characters. |
Thanks @jwdonahue. Confirm that these tests fail on --- a/test/sql/base.sql
+++ b/test/sql/base.sql
@@ -4,7 +4,7 @@ BEGIN;
\i test/pgtap-core.sql
\i sql/semver.sql
-SELECT plan(299);
+SELECT plan(303);
--SELECT * FROM no_plan();
SELECT has_type('semver');
@@ -25,7 +25,9 @@ SELECT lives_ok(
'1.0.0-1',
'1.0.0-alpha+d34dm34t',
'1.0.0+d34dm34t',
- '20110204.0.0'
+ '20110204.0.0',
+ '1.0.0-alpha.0a',
+ '1.0.0-0AEF'
]) AS v;
SELECT throws_ok(
@@ -43,7 +45,9 @@ SELECT throws_ok(
'1.4b.0',
'1v',
'1v.2.2v',
- '1.2.4b.5'
+ '1.2.4b.5',
+ '1.0.0-alpha.010',
+ '1.0.0-02799'
]) AS v;
-- Test =, <=, and >=. |
Just be careful not to create orphaned versions with your corrected code. I made that mistake once with an internal tool that got adopted about about 10K users in the first few months it was out. I would flag them with a warning when used and maybe provide a configuration flag to determine whether the user needs to fall-back to the broken behavior for existing data, but disallow creation of additional invalid strings. |
Yeah, I'll look through the PGXN database, but don't know what to do for other users of the extension other than call it out loudly in the changes on release. |
Fortunately, all the prerelease versions on PGXN have boring SemVer 1.0-style strings:
|
I second @jwdonahue. Been there, done that. |
Okay, I've pushed a fix. The issue where it previously allowed |
@theory, to be clear, the leading zero prohibition in numeric fields only applies to prerelease tags. Because the meta tag is not used for sorting, it does not have the distinction between numeric and alphanumeric fields. |
Also, there are many points in this documentation that are wrong. I can file bugs if you'd like, or wait for you take another pass at updating it with your current knowledge. One thing I would point out is that SemVer(X.Y.Z) != NonSemVer(X.Y.Z), so 1.2.0 != 1.2.00, because the later is not a semver string. You may want to have strict and nonstrict modes for this sort of thing, but a non-conforming string is less likely to carry the same semantics as a conforming string. I will be pushing hard for any SemVer 3.0.0 to also include a VersionMeta tag, to help clear up these ambiguities. |
Verified that leading |
As of right now:
If we wanted to eliminate the first case, we'd have to remove an implicit cast. Which I can see both ways, frankly. What happens is it implicitly casts the lhs value to a SemVer before making the comparison, so it will only work for a valid SemVer. I'll make a pass through the docs; I don't think we updated them when we added support for SemVer 2.0. |
I've made docs changes in #51. Let me know what I missed! |
In response to discussion on #45, properly prevent leading `0`s in prerelease parts only when there are no alphanumeric characters. Also fix an issue where it would ignore the first leading `0` in a prerelease no matter what else was in the part.
Thoughts on the documentation section I added warning folks about upgrading? Lines 72 to 98 in 97a7dfb
There's a variant of it in the Change file, too. I think for release I'll increment to v0.30.0 to denote the significance of the change. |
Only numeric identifiers of the prerelease version are forbidden from including leading zeroes. This should parse correctly as a version with base
1.0.0
and prerelease data[Alphanumeric("alpha"), Alphanumeric("0a")]
.The text was updated successfully, but these errors were encountered: