From 856d32c448a87245234315462d2190c5a9aab549 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Tue, 3 May 2022 10:05:28 +0300 Subject: feat! only store signed 64-bit plain integers in database This is a breaking change, but allows to store the largest signed 64-bit integers in SQLite and get it back. Sponsored-by: author --- src/db.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/db.rs b/src/db.rs index ab638a9..46ba16a 100644 --- a/src/db.rs +++ b/src/db.rs @@ -354,7 +354,7 @@ impl Column { } /// Type of plain integers that can be stored. -pub type DbInt = u64; +pub type DbInt = i64; /// A value in a named column. #[derive(Debug)] @@ -631,4 +631,17 @@ mod test { } assert_eq!(values, expected); } + + #[test] + fn round_trips_int_max() { + let tmp = tempdir().unwrap(); + let filename = tmp.path().join("test.db"); + let mut db = create_db(&filename); + insert(&mut db, DbInt::MAX); + db.close().unwrap(); + + let db = open_db(&filename); + let values = values(db); + assert_eq!(values, vec![DbInt::MAX]); + } } -- cgit v1.2.1