Document SQLite snapshot data mapping#42
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| var rows []struct { | ||
| Key string `json:"key"` | ||
| Category string `json:"category"` | ||
| SiteUnique string `json:"site_unique"` | ||
| PathUnique *string `json:"path_unique"` | ||
| Count int64 `json:"count"` | ||
| Payload string `json:"payload"` | ||
| PayloadTyp string `json:"payload_type"` |
There was a problem hiding this comment.
Allow NULL payloads when unmarshalling snapshots
The restore query returns payload as null for counter snapshots where no payload is stored. Unmarshalling that JSON into the Payload string field fails with json: cannot unmarshal null into Go value of type string, causing RestoreLatest to abort and skip restoring any keys. Use a nullable field (e.g. *string or json.RawMessage) so counter rows can be decoded and restoration proceeds.
Useful? React with 👍 / 👎.
| case categorySiteUV, categoryPageUV: | ||
| if len(rec.Payload) == 0 { | ||
| return errors.New("empty payload for hyperloglog restore") | ||
| } | ||
| return client.RestoreReplace(ctx, rec.Key, ttl, rec.Payload).Err() |
There was a problem hiding this comment.
RestoreReplace called with []byte payload
rec.Payload is a []byte, but redis.Client.RestoreReplace takes the serialized value as a string. Passing a byte slice will not compile and prevents the persistence module from building. Convert the payload to a string (or store it as a string) before calling RestoreReplace.
Useful? React with 👍 / 👎.
Summary
Testing
https://chatgpt.com/codex/tasks/task_b_68edbb370704832cac805263cf5d1a29