From be8442cfbee4742bd0a0d7a485ccb1e30db25b3e Mon Sep 17 00:00:00 2001 From: RumovZ Date: Tue, 7 Jun 2022 13:37:10 +0200 Subject: [PATCH] Fix deck export for notes with missing card 1 --- rslib/src/storage/deck/all_decks_of_search_notes.sql | 7 ++++--- rslib/src/storage/deck/mod.rs | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/rslib/src/storage/deck/all_decks_of_search_notes.sql b/rslib/src/storage/deck/all_decks_of_search_notes.sql index 0bf183f15..d6012ef3d 100644 --- a/rslib/src/storage/deck/all_decks_of_search_notes.sql +++ b/rslib/src/storage/deck/all_decks_of_search_notes.sql @@ -1,8 +1,9 @@ SELECT nid, did FROM cards -WHERE ord = 0 - AND nid IN ( +WHERE nid IN ( SELECT nid FROM search_nids - ) \ No newline at end of file + ) +GROUP BY nid +HAVING ord = MIN(ord) \ No newline at end of file diff --git a/rslib/src/storage/deck/mod.rs b/rslib/src/storage/deck/mod.rs index d31846fbb..cf408a42d 100644 --- a/rslib/src/storage/deck/mod.rs +++ b/rslib/src/storage/deck/mod.rs @@ -131,7 +131,7 @@ impl SqliteStorage { .collect() } - /// Returns the deck id of the first card of every searched note. + /// Returns the deck id of the first existing card of every searched note. pub(crate) fn all_decks_of_search_notes(&self) -> Result> { self.db .prepare_cached(include_str!("all_decks_of_search_notes.sql"))?