Skip to content

Fix schema SQL index output - #265

Merged
andrew merged 2 commits into
git-pkgs:mainfrom
abhinavgautam01:fix/schema-sql-indexes-259
Jul 8, 2026
Merged

andrew merged 2 commits into
git-pkgs:mainfrom
abhinavgautam01:fix/schema-sql-indexes-259

Conversation

@abhinavgautam01

Copy link
Copy Markdown
Contributor

Fixes #259

Summary

Fixes git pkgs schema --format sql so index definitions use real SQLite DDL instead of placeholder column lists like (...).

Changes

  • Read index SQL from sqlite_master.sql
  • Emit executable CREATE INDEX / CREATE UNIQUE INDEX statements in SQL output
  • Keep JSON/text/markdown index output as index names
  • Add regression coverage for real index columns in SQL output

Testing

  • go test ./cmd -run TestSchemaCommand
  • GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_NOSYSTEM=1 go test ./...
  • go tool golangci-lint run ./...

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes git pkgs schema --format sql output so index definitions are emitted as valid SQLite DDL, aligning the SQL schema output with what SQLite actually stores in sqlite_master.sql.

Changes:

  • Query sqlite_master for (name, sql) and retain index DDL internally for SQL output.
  • Emit executable CREATE INDEX / CREATE UNIQUE INDEX statements (with statement termination) in SQL format output.
  • Add regression assertions ensuring SQL output no longer contains (...) placeholders and includes expected index columns.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
cmd/schema.go Reads index DDL from sqlite_master.sql and prints real index DDL in SQL schema output.
cmd/database_test.go Adds regression coverage verifying SQL schema output contains real index columns and no placeholder (...).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/schema.go Resolved

@andrew andrew left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified locally: schema --format sql now emits real index DDL, JSON output unchanged, full suite + lint clean. Thanks!

@andrew
andrew merged commit c77a83b into git-pkgs:main Jul 8, 2026
4 checks passed
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.

schema --format sql emits invalid CREATE INDEX statements

3 participants