Skip to content

feat: add Floor/Ceil and TimeRange for time-based ID queries#5

Open
klaidliadon wants to merge 9 commits intomasterfrom
feat/timerange
Open

feat: add Floor/Ceil and TimeRange for time-based ID queries#5
klaidliadon wants to merge 9 commits intomasterfrom
feat/timerange

Conversation

@klaidliadon
Copy link
Copy Markdown
Contributor

Summary

  • Add FloorUUID, CeilUUID, FloorInt64, CeilInt64 — construct min/max boundary IDs for a given timestamp
  • Add generic TimeRange[T] type with ToSql() (structurally satisfies squirrel.Sqlizer) for range queries against PK indexes
  • Add UUIDRange and Int64Range constructors that accept *time.Time for optional since/until bounds

Test Plan

  • Floor/Ceil UUID: version, variant, bracketing, timestamp round-trip
  • Floor/Ceil Int64: bracketing, ordering
  • TimeRange.ToSql: all 4 since/until combinations (both, since-only, until-only, neither)
  • go test ./... passes

Add FloorUUID, CeilUUID, FloorInt64, CeilInt64 for constructing
boundary IDs from timestamps. Add generic TimeRange[T] with ToSql
for squirrel-compatible range queries against PK indexes.
Move Floor/Ceil functions and TimeRange type into timerange/ sub-package.
Add UUID and Int64 interfaces for prefix-erased type assertions.
Boundary IDs don't carry a prefix — return UUID/Int64 interfaces
from unexported concrete types instead of requiring a type parameter.
Drops the typeid import from the timerange package.
TimeRange is now a plain struct storing driver.Valuer bounds.
No generics left in the timerange package.
Replace two interfaces + two unexported concrete types with a single
generic ID[T int64 | uuid.UUID] struct. Type aliases UUID and Int64
preserve the familiar names.
Add GetTime/Floor/Ceil directly to UUID[P] and Int64[P]. Delete the
timerange sub-package and ID[T] generic type — no new types needed
since Floor/Ceil construct the existing types directly via val access.
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