Flagsmith / Flagsmith/flagsmith-sql-flag-engine

Semver: handle prerelease comparison

Đang mở Phù hợp với người mới
#5 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
1
Fork
0
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

`semver_sort_key` (in `translator._semver_sort_key_expr`) extracts the first three digit-runs from the version string, zero-pads each to 10 chars, and joins with dots. This gives correct major.minor.patch ordering but ignores prerelease: `1.2.3-beta` and `1.2.3` produce the same key.

Per [semver spec](https://semver.org/#spec-item-11), `1.2.3-beta < 1.2.3` (prerelease versions compare *less than* the corresponding release). My current implementation gets this wrong.

## What to ship

Extend the sort key with a prerelease tail. Approximation that's good enough for behavioural-targeting use:

- Extract everything after `-` (and before any `+` build metadata) as the prerelease string.
- Append a sentinel: `'~'` for absent prerelease (sorts after any prerelease alphabetically — `~` is high-ASCII), the literal prerelease string otherwise.
- Per-dot-segment numeric prerelease comparison is a further refinement (engine semver lib does this); skip for v1.

## Why deferred

Smoke-tested at 23/24 parity in the PoC; the one mismatch was the prerelease case described above. Customer segments using semver tend to use clean major.minor.patch (`app_version: "2.5.10"`) without prerelease tails. Will revisit if a customer reports an unexpected match for a `-beta` version.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Start at translator._semver_sort_key_expr and inspect the existing semver_sort_key behavior and its callers. Verify that versions such as 1.2.3-beta sort before 1.2.3, while build metadata does not affect the prerelease portion; done means the documented mismatch is corrected without requiring numeric prerelease-segment comparison.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python, sql
Lĩnh vực
databases
Loại issue
Lỗi
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
74/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.