Conversation
…rder (#299) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Greptile SummaryFixed non-deterministic include order in
Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[FormatMultiFile called] --> B[Group diffs by directory & object name]
B --> C[filesByType map created]
C --> D[Iterate orderedDirs]
D --> E{objects exist for directory?}
E -->|No| D
E -->|Yes| F[Extract object names from map]
F --> G[Sort object names alphabetically]
G --> H[Iterate sorted names]
H --> I[Write object file]
I --> J[Add include statement]
J --> K{More objects?}
K -->|Yes| H
K -->|No| L{More directories?}
L -->|Yes| D
L -->|No| M[Write main.sql with sorted includes]
M --> N[Return success]
style G fill:#90EE90
style F fill:#FFB6C1
Last reviewed commit: 586030a |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes non-deterministic output in pgschema dump --multi-file caused by random Go map iteration order when generating include statements in main.sql.
Changes:
- Sort object names alphabetically within each directory group before generating
\iinclude lines in multi-file dumps - Add comprehensive test that verifies deterministic output across 20 runs with multiple tables and functions
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/dump/formatter.go | Extract map keys to slice, sort alphabetically, then iterate sorted slice to generate deterministic include statements |
| cmd/dump/multifile_test.go | Add TestMultiFileIncludeOrderDeterministic to verify consistent sorted output across multiple runs |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pgschema dump --multi-fileiterated a Go map (map[string][]diff.Diff) without sorting keys, causing\iinclude lines inmain.sqlto appear in random order across runsFixes #299
Test plan
TestMultiFileIncludeOrderDeterministic— creates 4 tables + 2 functions, runsFormatMultiFile20 times, and verifies identical sorted output each timego test ./...)🤖 Generated with Claude Code