From f7e4b6d822c2ae80d4f763e2c47ffe32f60f305b Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 19 Mar 2021 22:57:43 +1000 Subject: [PATCH] fix spurious warning in db check for v1 scheduler+non-zero lapse ivl% https://forums.ankiweb.net/t/invalid-property-on-card-not-resolving-via-recommended-check-database/8430 --- rslib/src/dbcheck.rs | 2 ++ rslib/src/storage/card/fix_odue.sql | 2 ++ rslib/src/storage/card/mod.rs | 3 ++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/rslib/src/dbcheck.rs b/rslib/src/dbcheck.rs index 01a900026..42c0a90db 100644 --- a/rslib/src/dbcheck.rs +++ b/rslib/src/dbcheck.rs @@ -3,6 +3,7 @@ use crate::{ collection::Collection, + config::SchedulerVersion, err::{AnkiError, DBErrorKind, Result}, i18n::{tr_args, I18n, TR}, notetype::{ @@ -172,6 +173,7 @@ impl Collection { timing.days_elapsed, TimestampSecs::now(), self.usn()?, + self.scheduler_version() == SchedulerVersion::V1, )?; out.card_position_too_high = new_cnt; out.card_properties_invalid += other_cnt; diff --git a/rslib/src/storage/card/fix_odue.sql b/rslib/src/storage/card/fix_odue.sql index 87b636984..4e8156f74 100644 --- a/rslib/src/storage/card/fix_odue.sql +++ b/rslib/src/storage/card/fix_odue.sql @@ -6,6 +6,7 @@ SET odue = ( type = 1 OR queue = 2 ) + AND NOT ?3 AND NOT odid THEN 0 ELSE min(max(round(odue), -2147483648), 2147483647) END @@ -19,6 +20,7 @@ WHERE odue != ( type = 1 OR queue = 2 ) + AND NOT ?3 AND NOT odid THEN 0 ELSE min(max(round(odue), -2147483648), 2147483647) END diff --git a/rslib/src/storage/card/mod.rs b/rslib/src/storage/card/mod.rs index d04f2c051..69e63644e 100644 --- a/rslib/src/storage/card/mod.rs +++ b/rslib/src/storage/card/mod.rs @@ -230,6 +230,7 @@ impl super::SqliteStorage { today: u32, mtime: TimestampSecs, usn: Usn, + v1_sched: bool, ) -> Result<(usize, usize)> { let new_cnt = self .db @@ -242,7 +243,7 @@ impl super::SqliteStorage { other_cnt += self .db .prepare(include_str!("fix_odue.sql"))? - .execute(params![mtime, usn])?; + .execute(params![mtime, usn, v1_sched])?; other_cnt += self .db .prepare(include_str!("fix_ivl.sql"))?