Fernando Lins 81b44437f9 test: cover storage migration, revlog and filtered-deck ordering (#5650)
## 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.
2026-09-23 16:19:10 -03:00
2026-07-06 23:16:36 +08:00
2025-10-27 19:27:50 +07:00
2026-09-10 15:10:22 +01:00
2026-09-02 12:41:04 +03:00
2026-09-22 12:20:42 -03:00
2026-03-31 08:26:59 -04:00
2025-06-29 14:38:35 +07:00
2026-09-22 12:20:43 -03:00
2026-09-02 12:41:04 +03:00
2026-08-07 15:57:00 +03:00
2026-05-11 13:04:24 -04:00
2024-03-31 09:16:31 +01:00

Anki

Build Status Documentation Coverage

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

S
Description
GitHub Trending: ankitects/anki
Readme
513 MiB
Languages
Rust 37.5%
Python 22.9%
MDX 19.5%
TypeScript 9.5%
Svelte 8.9%
Other 1.3%