mirror of
https://github.com/ankitects/anki.git
synced 2026-10-02 05:24:38 +08:00
81b44437f90e93bd7c3a64afe3bcfad42c901c6d
## Linked issue Closes #5390 Refs #5407 (stale retrievability fallback) ## Summary / motivation Adds unit-test coverage for three under-tested storage areas called out in #5390, and fixes a bug found while writing it: - **storage/card/filtered.rs**: tests for `order_and_limit_for_search` across every `FilteredSearchOrder` variant, plus the Due/RelativeOverdueness and FSRS retrievability fragments. - **storage/revlog/mod.rs** (previously no tests): `add_revlog_entry` id-uniquify logic, get lookups, unknown-review-kind fallback, `time_of_last_review`, and the `studied_today` / `studied_today_by_deck` filters (window boundary, distinct-card counting, kind/factor rules). - **storage/sqlite.rs**: schema-version migration gating in `open_or_create` (FileTooOld / FileTooNew / the 12–13 special case) and the invariant that a rejected file is left untouched. - (Plus) **storage/upgrades/mod.rs**: a schema-11 downgrade→upgrade roundtrip proving migrated notetypes, decks, presets, config, tags and graves survive intact. **Bug fix (filtered.rs):** when a filtered deck kept a saved retrievability order after FSRS was disabled, `build_retrievability_query` returned an empty string, so `order_and_limit_for_search` produced SQL with a leading comma (`", fnvhash(...) limit N"`) that fails at runtime. It now falls back to `random()`, matching the filtered-deck dialog's behavior. ## Steps to reproduce 1. Create a filtered deck whose order is "Retrievability". 2. Enable FSRS, then later disable it (leaving the saved order in place). 3. Rebuild the filtered deck → the generated ordering SQL starts with a comma and errors instead of falling back to a valid order. ## How to test ### Details - `just test-rust` (new tests under `storage::card::filtered`, `storage::revlog`, `storage::sqlite`, `storage::upgrades`). - `just check` for the full format/lint/build/test gate. - The retrievability fix has a regression test (`retrievability_orders_fall_back_to_random_without_fsrs`) that builds a collection and runs the generated clause through `search_cards`, which would fail on the old leading-comma SQL.
Anki
This repo contains the source code for the computer version of Anki.
About
Anki is a spaced repetition program. Please see the website to learn more.
Getting Started
Contributing
Want to contribute to Anki? Check out the Contribution Guidelines.
For more information on building and developing, please see Development.
Contributors
The following people have contributed to Anki: CONTRIBUTORS
Anki Betas
If you'd like to try development builds of Anki but don't feel comfortable building the code, please see Anki betas.
License
Anki's license: LICENSE
Languages
Rust
37.5%
Python
22.9%
MDX
19.5%
TypeScript
9.5%
Svelte
8.9%
Other
1.3%