summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2022-05-03 10:05:28 +0300
committerLars Wirzenius <liw@liw.fi>2022-05-03 10:05:28 +0300
commit856d32c448a87245234315462d2190c5a9aab549 (patch)
tree010213f0ad296c14bb584d04a735b6f256293962
parentaad50a0827b5c74229153395f01e0eafdd64edf6 (diff)
downloadobnam2-856d32c448a87245234315462d2190c5a9aab549.tar.gz
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
-rw-r--r--src/db.rs15
1 files changed, 14 insertions, 1 deletions
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]);
+ }
}