Skip to content

feat(mock): alias __name__ to id in mocked _orderBy - #420

Merged
sinnaj-r merged 1 commit into
masterfrom
mock-alias-name-to-id
Jul 6, 2026
Merged

feat(mock): alias __name__ to id in mocked _orderBy#420
sinnaj-r merged 1 commit into
masterfrom
mock-alias-name-to-id

Conversation

@sinnaj-r

@sinnaj-r sinnaj-r commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

The mocked YustDatabaseService._orderBy reads the field value via _readValueInJsonDoc, which returns null for the reserved __name__ field name — sorting by __name__ then blows up on the .compareTo call.

Aliases __name__id in the mock so tests can freely add __name__ as a stable pagination tiebreaker (the same pattern _getListLazyChunked already uses internally, and the same alias the REST impl does via Cursor construction at yust_database_service_dart.dart:1330-1355).

Why now

Univelop's Records API v2 pagination fix appends __name__ as a tiebreaker to the orderBy sent to getListFromDB, mirroring the chunked-path pattern. That change makes uni_api pagination correct against real Firestore but breaks against the mocked DB — this small alias closes the parity gap.

Isolated from #419 (the paired getListFromDB cursor fix) — this one only touches the mock, so it can land and release independently.

Test plan

  • dart analyze clean
  • Verified end-to-end via Univelop's paginated record test suite once the univelop hotfix PR pins yust to this branch

🤖 Generated with Claude Code

Firestore addresses document IDs via the reserved `__name__` field
(both in query orderBy and in cursor construction). Yust stores
document IDs in the `id` field on every YustDoc, and every
YustDatabaseService method that touches Firestore's `__name__`
already handles the alias internally (see the Cursor construction
in yust_database_service_dart.dart:1330-1355 and the orderBy
augmentation in _getListLazyChunked).

The mocked database is the only impl that didn't recognize
`__name__`: `_orderBy` reads the field value via
`_readValueInJsonDoc`, which returns null for `__name__` (no such
field on a JSON doc) and blows up the `.compareTo` call.

Alias `__name__` → `id` in `_orderBy` so mock and REST behave
consistently. This makes it safe for callers of `getListFromDB` to
append `__name__` as a stable pagination tiebreaker (mirroring what
`_getListLazyChunked` already does internally) without breaking
mock-backed tests.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sinnaj-r
sinnaj-r merged commit aca95af into master Jul 6, 2026
@sinnaj-r
sinnaj-r deleted the mock-alias-name-to-id branch July 6, 2026 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant