fix error when gathering new cards in reverse position

Also simplify order clause - with did and queue limited to a constant,
SQLite is smart enough to use the covering index for sorting by due.
This commit is contained in:
Damien Elmes 2021-12-06 17:05:55 +10:00
parent fcb21ceed5
commit d515939340
2 changed files with 3 additions and 6 deletions

View File

@ -241,9 +241,9 @@ impl super::SqliteStorage {
F: FnMut(NewCard) -> bool,
{
let mut stmt = self.db.prepare_cached(&format!(
"{}{}",
"{} ORDER BY {}",
include_str!("new_cards.sql"),
if reverse { " order by due desc" } else { "" }
if reverse { "due desc" } else { "due asc" }
))?;
let mut rows = stmt.query(params![deck])?;
while let Some(row) = rows.next()? {

View File

@ -6,7 +6,4 @@ SELECT id,
odid
FROM cards
WHERE did = ?
AND queue = 0
ORDER BY did,
queue,
due
AND queue = 0