Fix deterministic template table index ordering #11

Merged
sgcommand merged 1 commits from fix/issue-10-deterministic-table-index into master 2026-07-19 14:11:11 +00:00
Member

Fixes the template writer path where values .Table.Indexes was backed by raw Go map iteration, causing repeated code generation from the same schema to emit indexes in different orders.

Changes:

  • Add a regression test that runs table-mode template generation repeatedly from one schema with multiple indexes and asserts byte-identical output plus stable alphabetical index ordering.
  • Sort map keys before exposing keys/values helper output, so generated template output no longer depends on Go map iteration order.

Verification:

  • TMPDIR=$PWD/.tmp GOCACHE=$PWD/go-cache go test ./pkg/writers/template -run TestWriterTableIndexValuesDeterministic -count=1
  • TMPDIR=$PWD/.tmp GOCACHE=$PWD/go-cache go test ./pkg/writers/template ./pkg/reflectutil -count=1
  • TMPDIR=$PWD/.tmp GOCACHE=$PWD/go-cache go test ./pkg/writers/... -count=1
  • TMPDIR=$PWD/.tmp GOCACHE=$PWD/go-cache go test ./... -count=1
  • TMPDIR=$PWD/.tmp GOCACHE=$PWD/go-cache make test
  • git diff --check

Refs #10

Fixes the template writer path where `values .Table.Indexes` was backed by raw Go map iteration, causing repeated code generation from the same schema to emit indexes in different orders. Changes: - Add a regression test that runs table-mode template generation repeatedly from one schema with multiple indexes and asserts byte-identical output plus stable alphabetical index ordering. - Sort map keys before exposing `keys`/`values` helper output, so generated template output no longer depends on Go map iteration order. Verification: - `TMPDIR=$PWD/.tmp GOCACHE=$PWD/go-cache go test ./pkg/writers/template -run TestWriterTableIndexValuesDeterministic -count=1` - `TMPDIR=$PWD/.tmp GOCACHE=$PWD/go-cache go test ./pkg/writers/template ./pkg/reflectutil -count=1` - `TMPDIR=$PWD/.tmp GOCACHE=$PWD/go-cache go test ./pkg/writers/... -count=1` - `TMPDIR=$PWD/.tmp GOCACHE=$PWD/go-cache go test ./... -count=1` - `TMPDIR=$PWD/.tmp GOCACHE=$PWD/go-cache make test` - `git diff --check` Refs #10
sgcommand added 1 commit 2026-07-19 13:57:33 +00:00
sgcommand merged commit 5c31deb630 into master 2026-07-19 14:11:11 +00:00
warkanum deleted branch fix/issue-10-deterministic-table-index 2026-07-19 19:24:41 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: wdevs/relspecgo#11