Skip to content

feat: TIME column type with granularity qualifier (#43) - #47

Merged
DDecoene merged 1 commit into
release/v1.2.0from
feature/43-time-column-type
Jul 9, 2026
Merged

feat: TIME column type with granularity qualifier (#43)#47
DDecoene merged 1 commit into
release/v1.2.0from
feature/43-time-column-type

Conversation

@DDecoene

@DDecoene DDecoene commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Closes #43.

Summary

  • New TIME column type (CREATE TABLE ... col TIME), storage HH:MM text, same family as DATE/CHAR.
  • Optional granularity qualifier TIME(n) (e.g. TIME(15) for quarter-hour increments) — parsing was already free via the existing CHAR(n)/NUM(p,s) grammar.
  • New ColumnMetaStore (data/system.sqlite3, mirrors IndexStore's shape) tracks base type + qualifier per column, since SQLite's own type affinity can't distinguish TIME from CHAR/DATE (all map to TEXT).
  • REPLACE ... WITH validates against the column's TIME/TIME(n) metadata and rejects malformed or off-granularity values with a clear ** Error: ... — no silent coercion. APPEND RECORD defaults are always NULL, which is left unvalidated (matches existing behavior for every other type).
  • LIST STRUCTURE prints the declared type (TIME, TIME(15)) instead of the raw SQLite storage class for columns tracked in ColumnMetaStore.
  • DROP TABLE / ALTER TABLE DROP / RENAME / ALTER keep the metadata consistent (drop/rename/clear as appropriate).
  • Assistant parity: the New table wizard offers TIME with an optional granularity field; Modify structure offers TIME as a retype target.

Scope notes

  • ALTER TABLE ADD/ALTER ... TIME(n) does not carry the qualifier through (existing skipTypeSize() behavior for all types, e.g. CHAR(n) size is already ignored on ALTER TABLE — consistent, not a regression). Only CREATE TABLE captures the qualifier. Noting this explicitly per the issue's guidance to confirm/extend only if needed — full ALTER TABLE qualifier support wasn't requested and adds parser/executor surface without a driving use case yet.
  • ModStructWizard's existing w3type() detection (raw SQLite type → picker default) can't detect an existing TIME column and will default it to CHAR — pre-existing limitation of that heuristic, not new.

Test plan

  • npm test — 272/272 vitest (18 files), including new tests/TimeType.test.ts (7 cases: creation, structure listing, valid/invalid/out-of-range REPLACE, granularity accept/reject, NULL-safe APPEND).
  • npx playwright test — 74/74 (was 73), new case in tests/assistant.spec.ts drives the New table wizard end-to-end (TIME(15) column, LIST STRUCTURE, reject 08:07, accept 08:15, LIST shows the committed value).
  • npx tsc --noEmit clean.

Add TIME/TIME(n) as a first-class CREATE TABLE column type, stored
as HH:MM text. The optional TIME(n) qualifier requires minutes to be
a multiple of n (e.g. TIME(15) for quarter-hour increments).

A new ColumnMetaStore (data/system.sqlite3, same pattern as
IndexStore) tracks base type + qualifier per column since SQLite's
own type affinity can't distinguish TIME from CHAR/DATE (all TEXT).
REPLACE ... WITH validates against it and rejects malformed or
off-granularity values instead of silently coercing them; LIST
STRUCTURE prints the declared type. The New table wizard and Modify
structure wizard both offer TIME as a column type.
@DDecoene
DDecoene merged commit 489c796 into release/v1.2.0 Jul 9, 2026
2 checks passed
@DDecoene
DDecoene deleted the feature/43-time-column-type branch July 9, 2026 16:45
@DDecoene DDecoene mentioned this pull request Jul 9, 2026
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