From cf3945548751dba6d0bc96b170018c2820774492 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Mon, 26 Jun 2023 13:40:40 +1000 Subject: [PATCH] Handle invalid float mtimes in DB check Likely an add-on or third-party tool created them, and they were breaking DB queries for a user. https://sqlite.org/stricttables.html could help us avoid this class of issue in the future, though we'd need to check what client versions we'd break with this change, and would need to change the 'sfld is an integer' hack. --- rslib/src/storage/card/fix_mod.sql | 3 +++ rslib/src/storage/card/mod.rs | 4 ++++ 2 files changed, 7 insertions(+) create mode 100644 rslib/src/storage/card/fix_mod.sql diff --git a/rslib/src/storage/card/fix_mod.sql b/rslib/src/storage/card/fix_mod.sql new file mode 100644 index 000000000..7b15b0e54 --- /dev/null +++ b/rslib/src/storage/card/fix_mod.sql @@ -0,0 +1,3 @@ +UPDATE cards +SET mod = cast(mod AS integer) +WHERE mod != cast(mod AS integer) \ No newline at end of file diff --git a/rslib/src/storage/card/mod.rs b/rslib/src/storage/card/mod.rs index 3dd981b98..1a16c0c6d 100644 --- a/rslib/src/storage/card/mod.rs +++ b/rslib/src/storage/card/mod.rs @@ -353,6 +353,10 @@ impl super::SqliteStorage { .db .prepare(include_str!("fix_ivl.sql"))? .execute(params![mtime, usn])?; + other_cnt += self + .db + .prepare(include_str!("fix_mod.sql"))? + .execute(params![])?; other_cnt += self .db .prepare(include_str!("fix_ordinal.sql"))?