The charger list sorted by a field the collection never had

Opening Home chargers answered {"status":400,"message":"Something went wrong
while processing your request."} — PocketBase's generic refusal, here for an
unknown sort field. home_chargers declares its own fields and nothing else:
PocketBase adds no created field to a collection defined through the API, which
is exactly why control_audit and organizations declare theirs. The list handler
sorted by created anyway. It was the only handler in the server that sorts by
created — every other one sorts by name, km or date, fields their collections
actually declare — so the gap had never had a chance to show.

The field is now declared, and reconcile adds it to the collection already
standing on the next boot, since home_chargers is in reconcileOrder. Import order
is the only order a charger has: it carries no date of its own, and a wallbox
bolted to a wall does not accumulate events the way a car does.

The list also stops depending on that. A rejected sort now falls back to the
unsorted query rather than failing the request: the order is a nicety, the list
is not, and an owner reading a database error about a field they cannot see is
the worst of both. It also makes the deploy order stop mattering — the page works
before the bootstrap has run, and the sorted query wins once it has.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
tajniak81
2026-08-31 21:34:48 +02:00
co-authored by Claude Opus 5
parent 06f91578da
commit 423bc2ab16
3 changed files with 28 additions and 5 deletions
+5
View File
@@ -219,6 +219,11 @@ var collectionsSchema = map[string][]fieldDef{
// Owner. Non-cascading, like a car's: deleting a user must not silently
// wipe the records they own.
fRelation("owner", "users", false, false),
// A charger carries no date of its own, so the import order is the only
// order there is to list them in. PocketBase adds no created field to a
// collection defined through the API, so it is declared here like the
// audit trail's.
fAutodate("created", true, false),
},
// Custom fields layered onto the built-in "users" auth collection.
"users": {