- persist: formatTime 定宽;loadLatestSQL 补 rowid 兜底;New 时归一化历史行(避免 LoadLatest 挑到更旧检查点) - channel/session: 写入定宽;listSessionSQL 补 rowid 兜底;核实无 INSERT 吃 DDL 默认值,故只加注释不改默认值 - 新增回归测试并做变异验证(改回 RFC3339Nano 即 FAIL)
22 lines
905 B
Go
22 lines
905 B
Go
package session
|
|
|
|
import "time"
|
|
|
|
// sessionTimeLayout is the fixed-width timestamp layout used for every stored
|
|
// created_at/updated_at value. Unlike time.RFC3339Nano it never drops trailing
|
|
// fractional zeros, so every value is exactly sessionTimeLen bytes wide. SQLite
|
|
// compares these TEXT columns as plain strings, and equal width is what makes
|
|
// that comparison agree with chronological order. Values are written in UTC, so
|
|
// the Z07:00 zone renders as a single "Z".
|
|
const sessionTimeLayout = "2006-01-02T15:04:05.000000000Z07:00"
|
|
|
|
// sessionTimeLen is the byte length of a UTC value formatted with
|
|
// sessionTimeLayout: "2006-01-02T15:04:05.000000000Z" — the Z07:00 zone
|
|
// collapses to "Z" in UTC.
|
|
const sessionTimeLen = 30
|
|
|
|
// formatSessionTime encodes t in UTC with the fixed-width sessionTimeLayout.
|
|
func formatSessionTime(t time.Time) string {
|
|
return t.UTC().Format(sessionTimeLayout)
|
|
}
|