mirror of
https://github.com/Donkie/Spoolman.git
synced 2026-10-22 01:52:17 -05:00
Sorting the library by "last used" led with everything that had never been used, on PostgreSQL and CockroachDB. Those two default to NULLS FIRST on DESC, while SQLite and MySQL treat NULL as the lowest value and put it last; `last_used` is NULL until a spool is first used, so the default library ordering came out inverted for half the supported databases (#984, #985). Grouped views showed it worst: a group's date is the max over its spools, so a filament holding nothing but unused spools aggregates to NULL and floated to the top, above filaments used minutes ago. order_by_clauses() now orders on an explicit "is it null" flag ahead of the field itself, so an absent value sorts last in both directions everywhere. It is written as `expr IS NULL` rather than SQLAlchemy's nullslast(), which renders a literal NULLS LAST that MySQL and MariaDB reject. Applied to every sort site -- spools, groups, filaments, vendors, extra fields -- so ordering no longer depends on which database is underneath. Verified against all four: 438 integration tests pass on SQLite, PostgreSQL, MariaDB and CockroachDB, and both new regression tests fail on PostgreSQL without the fix. Claude-Session: https://claude.ai/code/session_01EaLK21WpQYDE1DkKwZHK3P