All checks were successful
Run Check Script / check (pull_request) Successful in 2m15s
`physical_hosts.version_id` is `Id::default().to_string()`, which
formats `{masked_hex_timestamp}_{rand7}`. Two problems for using that
as a "latest row" key:
1. `format!("{:x}", v)` is variable-length. When the masked 24-bit
clock crosses a hex-width boundary (every few days at most, ±18h
or 12 days from cycle start), lexicographic comparison breaks:
`'_'` (0x5F) > any digit, so "1234_…" sorts HIGHER than
"123456_…" even though the latter was saved later.
2. The timestamp is masked to 24 bits, wrapping every ~194 days.
Net effect: `MAX(version_id)` in get_all_hosts / get_latest_by_id /
save's dedupe lookup can return an OLD row instead of the most
recently inserted one — exactly the "stale IP in the Select" the user
reported after re-adding a previously-deleted node.
Fix: order by SQLite's implicit `rowid` instead — strictly monotonic
INSERT counter, always reflects real save order. physical_hosts is
not WITHOUT ROWID, so rowid is always there. The version_id column
stays on every row (useful in the UI / audit logs) but no longer
drives ranking.
Id::default() is untouched; it's used throughout the codebase and
fixing the format is a separate, wider change.
sqlx offline cache regenerated.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
33 lines
686 B
JSON
33 lines
686 B
JSON
{
|
|
"db_name": "SQLite",
|
|
"query": "SELECT id, version_id, data as \"data: Json<PhysicalHost>\" FROM physical_hosts WHERE id = ? ORDER BY rowid DESC LIMIT 1",
|
|
"describe": {
|
|
"columns": [
|
|
{
|
|
"name": "id",
|
|
"ordinal": 0,
|
|
"type_info": "Text"
|
|
},
|
|
{
|
|
"name": "version_id",
|
|
"ordinal": 1,
|
|
"type_info": "Text"
|
|
},
|
|
{
|
|
"name": "data: Json<PhysicalHost>",
|
|
"ordinal": 2,
|
|
"type_info": "Null"
|
|
}
|
|
],
|
|
"parameters": {
|
|
"Right": 1
|
|
},
|
|
"nullable": [
|
|
false,
|
|
false,
|
|
false
|
|
]
|
|
},
|
|
"hash": "36273d65f86cd9070b278a3c3da4ea16e21311f4ba579522282499ac5c62bd5e"
|
|
}
|