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

cljoly / rusqlite_migration / 14021342810
94%
master: 95%

Build:
Build:
LAST BUILD BRANCH: dependabot/cargo/insta-1.45.0
DEFAULT BRANCH: master
Ran 23 Mar 2025 05:30PM UTC
Jobs 1
Files 4
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 05:28PM UTC coverage: 93.226% (-1.4%) from 94.649%
14021342810

Pull #241

github

cljoly
fix: return explicit errors when user_version is wrong

Prior to this change, if we read a negative [user version][uv_offset],
it will be converted to a `usized`. 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
Pull Request #241: fix: return explicit errors when user_version is wrong

10 of 15 new or added lines in 2 files covered. (66.67%)

1 existing line in 1 file now uncovered.

289 of 310 relevant lines covered (93.23%)

6.21 hits per line

New Missed Lines in Diff

Lines Coverage ∆ File
1
97.73
-2.27% rusqlite_migration/src/errors.rs
4
90.95
-1.68% rusqlite_migration/src/lib.rs

Uncovered Existing Lines

Lines Coverage ∆ File
1
97.73
-2.27% rusqlite_migration/src/errors.rs
Jobs
ID Job ID Ran Files Coverage
1 14021342810.1 23 Mar 2025 05:30PM UTC 4
93.23
GitHub Action Run
Source Files on build 14021342810
  • Tree
  • List 4
  • Changed 2
  • Source Changed 0
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Pull Request #241
  • PR Base - master (#13887637215)
  • 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