• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

cljoly / rusqlite_migration / 14023796930
95%

Build:
DEFAULT BRANCH: master
Ran 23 Mar 2025 10:56PM UTC
Jobs 1
Files 5
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

23 Mar 2025 10:53PM UTC coverage: 93.994% (-0.7%) from 94.649%
14023796930

push

github

web-flow
fix: return explicit errors when user_version is wrong (#241)

Prior to this change, if we read a negative [user version][uv_offset],
it will be converted to a `usize`. This often results in high numbers,
that are outside the range of defined migrations. This would thus likely
return a “migration out of bounds”-type error.

This fixes this, explicitly checking that the conversion to `usize` goes
well and returning an error if not.

While we are touching this, also specify the maximum number of
migrations supported. This should make implementing
https://github.com/cljoly/rusqlite_migration/issues/170 easier.

Alternative options
-------------------

I have considered using a `i32` everywhere instead (since we are about
to break compatibility with a 2.0 version), but then I have to convert
back and forth with `usize` in multiple places. This is error prone.
Another drawback is that we won’t get compile time errors for negative
numbers (`i32` is a signed type) and that is a more likely mistake than
passing a number of migrations higher than about 2 billion.

Unfortunately, there is no Rust type in the standard library that has
both of those constraints:
* `>= 0`
* `<= i32::MAX`
(u32 comes to mind, but `u32::MAX` is still too big).

Thus it seems easier to just stick with the standard library type and
return an error if the user passes numbers higher than i32::MAX. Using a
custom type in `to_version` seems excessively verbose and has almost no
benefits: if the user is to create a value in this custom type from a
`i32` or a `usize`, they still have to handle corner cases like negative
numbers or values higher than `i32::MAX`.

[uv_offset]: https://www.sqlite.org/fileformat.html#user_version_number

35 of 39 new or added lines in 3 files covered. (89.74%)

313 of 333 relevant lines covered (93.99%)

5.87 hits per line

New Missed Lines in Diff

Lines Coverage ∆ File
4
90.95
-1.68% rusqlite_migration/src/lib.rs
Jobs
ID Job ID Ran Files Coverage
1 14023796930.1 23 Mar 2025 10:56PM UTC 5
93.99
GitHub Action Run
Source Files on build 14023796930
  • Tree
  • List 5
  • Changed 2
  • Source Changed 0
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • 00e82f66 on github
  • Prev Build on master (#13887637215)
  • Next Build on master (#14045390469)
  • Delete
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc