Skip to content

Disable u64, usize ToSql/FromSql impl by default#1732

Merged
gwenn merged 3 commits into
rusqlite:masterfrom
gwenn:fallible_uint
Oct 4, 2025
Merged

Disable u64, usize ToSql/FromSql impl by default#1732
gwenn merged 3 commits into
rusqlite:masterfrom
gwenn:fallible_uint

Conversation

@gwenn

@gwenn gwenn commented Aug 30, 2025

Copy link
Copy Markdown
Collaborator

Use fallible_uint feature to have them back
Fix #1722

Use `fallible_uint` feature to have them back
@codecov

codecov Bot commented Aug 30, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.91%. Comparing base (fe44105) to head (cc64ff2).
⚠️ Report is 10 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1732   +/-   ##
=======================================
  Coverage   86.91%   86.91%           
=======================================
  Files          58       58           
  Lines       10642    10644    +2     
=======================================
+ Hits         9249     9251    +2     
  Misses       1393     1393           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mqudsi

mqudsi commented Aug 30, 2025

Copy link
Copy Markdown
Contributor

Thank you. Would you also take a PR to additionally introduce an i64-casting variant? Too bad rust features can’t take values (like c defines or cmake vars).

@gwenn

gwenn commented Aug 30, 2025

Copy link
Copy Markdown
Collaborator Author

Thank you. Would you also take a PR to additionally introduce an i64-casting variant? Too bad rust features can’t take values (like c defines or cmake vars).

I would prefer to do like rust-postgres and have no support for u64 by default.
Because, without native support, many operators / functions cannot be used anymore.

@mqudsi

mqudsi commented Sep 1, 2025

Copy link
Copy Markdown
Contributor

Sorry, I meant as an additional feature, eg casting_u64.

@gwenn

gwenn commented Sep 1, 2025

Copy link
Copy Markdown
Collaborator Author

I mean at least:

SELECT abs(u64), sign(u64), u64 % 2 FROM tbl;

doesn't work when u64 contains values casted as i64.

@mqudsi

mqudsi commented Sep 1, 2025

Copy link
Copy Markdown
Contributor

You’re right, that’s probably a little too much for something people might enable that easily.

I have no hard preference either way, but how do you feel fallible_uint removal from default should play with the crate version number? If the code were completely dropped, technically the semantic version should be a full major version increment but if it’s “just” gated behind a non-default feature?

@gwenn

gwenn commented Sep 2, 2025

Copy link
Copy Markdown
Collaborator Author

As there is still no major version of rusqlite, doing breaking changes is easy.

@gwenn gwenn merged commit 66e6b67 into rusqlite:master Oct 4, 2025
16 checks passed
@gwenn gwenn deleted the fallible_uint branch October 4, 2025 08:26
EliahKagan added a commit to GitoxideLabs/gitoxide 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
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 GitoxideLabs/gitoxide 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
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 GitoxideLabs/gitoxide 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
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
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
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
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 GitoxideLabs/gitoxide 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)
coriolinus added a commit to wireapp/core-crypto that referenced this pull request Mar 10, 2026
In v0.38, rusqlite fixed a logical problem: casting values to/from
unsigned 64-bit values was sometimes causing runtime errors, because
internally sqlite only knows about signed 64-bit integers.

The problem: rusqlite/rusqlite#1722
The fix: rusqlite/rusqlite#1732

This was a problem for us because we use u64s to represent timestamps
in the keystore.

This commit chooses to just add the feature flag which reenables
the old behavior. We're not going to be maintaining this code
anymore once the potential to overflow an i64 with a unix timestamp
is a reasonable possibility, and we're not using that type in other
contexts, so we should be fine.

I did consider the alternative of changing the underlying type
from u64 to i64. However, that would have meant a cascading series
of pointless changes all the way up to the ffi layer, and it just
did not seem worth it. So I rejected that for now.
coriolinus added a commit to wireapp/core-crypto that referenced this pull request Mar 10, 2026
In v0.38, rusqlite fixed a logical problem: casting values to/from
unsigned 64-bit values was sometimes causing runtime errors, because
internally sqlite only knows about signed 64-bit integers.

The problem: rusqlite/rusqlite#1722
The fix: rusqlite/rusqlite#1732

This was a problem for us because we use u64s to represent timestamps
in the keystore.

This commit chooses to just add the feature flag which reenables
the old behavior. We're not going to be maintaining this code
anymore once the potential to overflow an i64 with a unix timestamp
is a reasonable possibility, and we're not using that type in other
contexts, so we should be fine.

I did consider the alternative of changing the underlying type
from u64 to i64. However, that would have meant a cascading series
of pointless changes all the way up to the ffi layer, and it just
did not seem worth it. So I rejected that for now.
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.

Default u64 ToSql/FromSql impl invariably leads to issues

2 participants