Skip to content

Fix rusqlite 0.38.0 compatibility: cast usize/u64 to i64 for database operations#2331

Merged
Byron merged 3 commits intodependabot/cargo/cargo-e31022c64efrom
copilot/sub-pr-2330
Jan 2, 2026
Merged

Fix rusqlite 0.38.0 compatibility: cast usize/u64 to i64 for database operations#2331
Byron merged 3 commits intodependabot/cargo/cargo-e31022c64efrom
copilot/sub-pr-2330

Conversation

Copy link
Contributor

Copilot AI commented Jan 2, 2026

Rusqlite 0.38.0 removed FromSql and ToSql trait implementations for usize and u64 types, causing compilation failures in the corpus and query features.

Changes

  • Cast database types: All usize and u64 values are now cast to i64 when inserting/updating, and cast back when reading from the database
  • Add missing dependency: Added crossbeam-channel to the query feature (was only in corpus and estimate-hours)
  • Fix borrow issue: Replaced problematic std::mem::replace with std::mem::take to avoid RefMut lifetime conflicts

Example

// Before (compilation error)
let version: Option<usize> = con.query_row("SELECT version FROM meta", [], |r| r.get(0)).optional()?;
con.execute("INSERT into meta(version) values(?)", params![VERSION])?;

// After
let version: Option<i64> = con.query_row("SELECT version FROM meta", [], |r| r.get(0)).optional()?;
let version = version.map(|v| v as usize);
con.execute("INSERT into meta(version) values(?)", params![VERSION as i64])?;

Note: The query feature has a pre-existing Send trait bound issue unrelated to these changes.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: Byron <63622+Byron@users.noreply.github.com>
Copilot AI changed the title [WIP] Bump cargo group across directory with 54 updates Fix rusqlite 0.38.0 compatibility: cast usize/u64 to i64 for database operations Jan 2, 2026
Copilot AI requested a review from Byron January 2, 2026 15:09
@Byron Byron marked this pull request as ready for review January 2, 2026 16:10
@Byron Byron merged commit 5d90e65 into dependabot/cargo/cargo-e31022c64e Jan 2, 2026
@Byron Byron deleted the copilot/sub-pr-2330 branch January 2, 2026 16:11
Copy link
Member

@EliahKagan EliahKagan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were two ways #2330 (comment) could've been fixed, and I don't have any specific concern about the way chosen here, but I wanted to bring up the other way, just in case it should be considered. This PR description says:

Rusqlite 0.38.0 removed FromSql and ToSql trait implementations for usize and u64 types, causing compilation failures in the corpus and query features.

That's not entirely accurate. At least going by rusqlite/rusqlite#1732 (linked from the v0.38.0 announcement), the trait implementations were not removed from rusqlite, but instead placed behind a new fallible_uint feature flag.

So it seems to me that enabling that flag is another way this could've been fixed here. I don't know which way is better.

The context in rusqlite/rusqlite#1722 may be relevant. But it's not immediately obvious to me if the concerns apply to any use by gitoxide-core of rusqlite.

@Byron
Copy link
Member

Byron commented Jan 2, 2026

Thanks so much for checking this! Admittedly I didn't and just left it to the machine.
Using the feature toggle would be way better.
Thus, both commits (copilot + refactor) can be reverted in favor of using the new feature.

In future, I will wait for you to take a look, like it was done before as well 😅.

Is this a fix you want to do? I am also happy to fix it up otherwise.

@EliahKagan
Copy link
Member

Is this a fix you want to do?

Sure! If I encounter problems, I'll let you know.

EliahKagan added a commit that referenced this pull request Jan 2, 2026
As first seen for gitoxide in #2330, upgrading `rusqlite` to 0.38.0
breaks compatibility with some of the types we use with it. This is
due to a change in `rusqlite` that places conversions for `u64` and
`usize` behind the new `fallible_uint` feature flag:

- rusqlite/rusqlite#1722
- rusqlite/rusqlite#1732

We originally fixed this in #2331 (modifying #2330) by casting.
This instead fixes it by enabling the new `fallible_uint` feature.

For relevant details, see:

- #2331 (review)
- #2331 (comment)
EliahKagan added a commit to EliahKagan/gitoxide that referenced this pull request Jan 3, 2026
This reverts the preceding two commits from GitoxideLabs#2331 (see discussion
there). This prepares for a different, immediately forthcoming fix.
EliahKagan added a commit to EliahKagan/gitoxide that referenced this pull request Jan 3, 2026
As first seen for gitoxide in GitoxideLabs#2330, upgrading `rusqlite` to 0.38.0
breaks compatibility with some of the types we use with it. This is
due to a change in `rusqlite` that places conversions for `u64` and
`usize` behind the new `fallible_uint` feature flag:

- rusqlite/rusqlite#1722
- rusqlite/rusqlite#1732

We originally fixed this in GitoxideLabs#2331 (modifying GitoxideLabs#2330) by casting.
This instead fixes it by enabling the new `fallible_uint` feature.

For relevant details, see:

- GitoxideLabs#2331 (review)
- GitoxideLabs#2331 (comment)
EliahKagan added a commit that referenced this pull request Jan 3, 2026
This reverts the preceding two commits from #2331 (see discussion
there). This prepares for a different, immediately forthcoming fix.
EliahKagan added a commit that referenced this pull request Jan 3, 2026
As first seen for gitoxide in #2330, upgrading `rusqlite` to 0.38.0
breaks compatibility with some of the types we use with it. This is
due to a change in `rusqlite` that places conversions for `u64` and
`usize` behind the new `fallible_uint` feature flag:

- rusqlite/rusqlite#1722
- rusqlite/rusqlite#1732

We originally fixed this in #2331 (modifying #2330) by casting.
This instead fixes it by enabling the new `fallible_uint` feature.

For relevant details, see:

- #2331 (review)
- #2331 (comment)
EliahKagan added a commit to EliahKagan/gitoxide that referenced this pull request Jan 3, 2026
This reverts the preceding two commits from GitoxideLabs#2331 (see discussion
there). This prepares for a different, immediately forthcoming fix.
EliahKagan added a commit to EliahKagan/gitoxide that referenced this pull request Jan 3, 2026
As first seen for gitoxide in GitoxideLabs#2330, upgrading `rusqlite` to 0.38.0
breaks compatibility with some of the types we use with it. This is
due to a change in `rusqlite` that places conversions for `u64` and
`usize` behind the new `fallible_uint` feature flag:

- rusqlite/rusqlite#1722
- rusqlite/rusqlite#1732

We originally fixed this in GitoxideLabs#2331 (modifying GitoxideLabs#2330) by casting.
This instead fixes it by enabling the new `fallible_uint` feature.

For relevant details, see:

- GitoxideLabs#2331 (review)
- GitoxideLabs#2331 (comment)
EliahKagan added a commit that referenced this pull request Jan 3, 2026
This reverts the preceding two commits from #2331 (see discussion
there). This prepares for a different, immediately forthcoming fix.
EliahKagan added a commit that referenced this pull request Jan 3, 2026
As first seen for gitoxide in #2330, upgrading `rusqlite` to 0.38.0
breaks compatibility with some of the types we use with it. This is
due to a change in `rusqlite` that places conversions for `u64` and
`usize` behind the new `fallible_uint` feature flag:

- rusqlite/rusqlite#1722
- rusqlite/rusqlite#1732

We originally fixed this in #2331 (modifying #2330) by casting.
This instead fixes it by enabling the new `fallible_uint` feature.

For relevant details, see:

- #2331 (review)
- #2331 (comment)
EliahKagan added a commit to EliahKagan/gitoxide that referenced this pull request Jan 4, 2026
This reverts the preceding two commits from GitoxideLabs#2331 (see discussion
there). This prepares for a different, immediately forthcoming fix.
EliahKagan added a commit to EliahKagan/gitoxide that referenced this pull request Jan 4, 2026
As first seen for gitoxide in GitoxideLabs#2330, upgrading `rusqlite` to 0.38.0
breaks compatibility with some of the types we use with it. This is
due to a change in `rusqlite` that places conversions for `u64` and
`usize` behind the new `fallible_uint` feature flag:

- rusqlite/rusqlite#1722
- rusqlite/rusqlite#1732

We originally fixed this in GitoxideLabs#2331 (modifying GitoxideLabs#2330) by casting.
This instead fixes it by enabling the new `fallible_uint` feature.

For relevant details, see:

- GitoxideLabs#2331 (review)
- GitoxideLabs#2331 (comment)
EliahKagan added a commit to EliahKagan/gitoxide that referenced this pull request Jan 4, 2026
This reverts the preceding two commits from GitoxideLabs#2331 (see discussion
there). This prepares for a different, immediately forthcoming fix.
EliahKagan added a commit to EliahKagan/gitoxide that referenced this pull request Jan 4, 2026
As first seen for gitoxide in GitoxideLabs#2330, upgrading `rusqlite` to 0.38.0
breaks compatibility with some of the types we use with it. This is
due to a change in `rusqlite` that places conversions for `u64` and
`usize` behind the new `fallible_uint` feature flag:

- rusqlite/rusqlite#1722
- rusqlite/rusqlite#1732

We originally fixed this in GitoxideLabs#2331 (modifying GitoxideLabs#2330) by casting.
This instead fixes it by enabling the new `fallible_uint` feature.

For relevant details, see:

- GitoxideLabs#2331 (review)
- GitoxideLabs#2331 (comment)
EliahKagan added a commit to EliahKagan/gitoxide that referenced this pull request Jan 4, 2026
This reverts the preceding two commits from GitoxideLabs#2331 (see discussion
there). This prepares for a different, immediately forthcoming fix.
EliahKagan added a commit to EliahKagan/gitoxide that referenced this pull request Jan 4, 2026
As first seen for gitoxide in GitoxideLabs#2330, upgrading `rusqlite` to 0.38.0
breaks compatibility with some of the types we use with it. This is
due to a change in `rusqlite` that places conversions for `u64` and
`usize` behind the new `fallible_uint` feature flag:

- rusqlite/rusqlite#1722
- rusqlite/rusqlite#1732

We originally fixed this in GitoxideLabs#2331 (modifying GitoxideLabs#2330) by casting.
This instead fixes it by enabling the new `fallible_uint` feature.

For relevant details, see:

- GitoxideLabs#2331 (review)
- GitoxideLabs#2331 (comment)
EliahKagan added a commit to EliahKagan/gitoxide that referenced this pull request Jan 4, 2026
This reverts the preceding two commits from GitoxideLabs#2331 (see discussion
there). This prepares for a different, immediately forthcoming fix.
EliahKagan added a commit to EliahKagan/gitoxide that referenced this pull request Jan 4, 2026
As first seen for gitoxide in GitoxideLabs#2330, upgrading `rusqlite` to 0.38.0
breaks compatibility with some of the types we use with it. This is
due to a change in `rusqlite` that places conversions for `u64` and
`usize` behind the new `fallible_uint` feature flag:

- rusqlite/rusqlite#1722
- rusqlite/rusqlite#1732

We originally fixed this in GitoxideLabs#2331 (modifying GitoxideLabs#2330) by casting.
This instead fixes it by enabling the new `fallible_uint` feature.

For relevant details, see:

- GitoxideLabs#2331 (review)
- GitoxideLabs#2331 (comment)
EliahKagan added a commit that referenced this pull request Jan 4, 2026
This reverts the preceding two commits from #2331 (see discussion
there). This prepares for a different, immediately forthcoming fix.
EliahKagan added a commit that referenced this pull request Jan 4, 2026
As first seen for gitoxide in #2330, upgrading `rusqlite` to 0.38.0
breaks compatibility with some of the types we use with it. This is
due to a change in `rusqlite` that places conversions for `u64` and
`usize` behind the new `fallible_uint` feature flag:

- rusqlite/rusqlite#1722
- rusqlite/rusqlite#1732

We originally fixed this in #2331 (modifying #2330) by casting.
This instead fixes it by enabling the new `fallible_uint` feature.

For relevant details, see:

- #2331 (review)
- #2331 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants