Commit 84c80f0
authored
feat(semver): Add fields to
This pr makes changes to the Release model so that we can support semver
sorting. The values for these fields will all be extracted from version if it fits our slightly
more permissive semver format:
<major>.<minor>.<patch>.<revision>-<prerelease>+<build_code>
These are all optional to varying extents. If a version does not match this format at all then
these fields will just be null. If we partially match, any fields not already included in the version
should be set to 0 or '' depending on field type. So 1.2 would have fields like
major=1, minor=2, patch=0, revision=0, prerelease=''. This is important, because we want to
use https://www.postgresql.org/docs/current/functions-comparisons.html#ROW-WISE-COMPARISON
to filter these rows, and nulls cause the comparison to return False where we wouldn't expect.
If build_code is entirely numeric we will parse it and store as build_number, which will allow
us to sort Android releases numerically.
I've added an index on (major, minor, patch, revision) with all the columns desc. We'll likely mostly be
sorting desc, so that seemed most helpful. This means that we'd sort in this order: 1.2.1, 1.2.0,
with 1.2.1 being the highest.
I've left prerelease out of the index, since I think that the number of prereleases per
patch or revision will be low, and it's probably nicer to keep the text field out of the index. To filter
correctly via semver, we need to add case when prerelease = '' then 1 else 0 end, prerelease to
our row comparison, so that rows without a prerelease end up being ranked as higher. This shouldn't
be slow, since most rows will have very few prereleases, but if we find that it is we can include these
fields in the index.Release to support semver filtering and sorting. (#25956)1 parent 443a1de commit 84c80f0
File tree
3 files changed
+122
-1
lines changed- src/sentry
- migrations
- models
3 files changed
+122
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
144 | 157 | | |
145 | 158 | | |
146 | 159 | | |
| |||
152 | 165 | | |
153 | 166 | | |
154 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
155 | 176 | | |
156 | 177 | | |
157 | 178 | | |
| |||
0 commit comments