Skip to content

Add support for statement diff#598

Merged
morgo merged 10 commits intoblock:mainfrom
morgo:mtocker-add-statement-diff
Feb 23, 2026
Merged

Add support for statement diff#598
morgo merged 10 commits intoblock:mainfrom
morgo:mtocker-add-statement-diff

Conversation

@morgo
Copy link
Collaborator

@morgo morgo commented Feb 22, 2026

A Pull Request should be associated with an Issue.

We wish to have discussions in Issues. A single issue may be targeted by multiple PRs.
If you're offering a new feature or fixing anything, we'd like to know beforehand in Issues,
and potentially we'll be able to point development in a particular direction.
Further notes in https://github.com/block/spirit/blob/main/.github/CONTRIBUTING.md

This adds support for statement diffing. It is not used by Spirit internally, but is part of the statement API which can be used before calling spirit.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds comprehensive support for statement diffing to the Spirit project. It introduces a new Diff() method that compares two CREATE TABLE statements and generates the necessary ALTER TABLE statement to transform one into the other. The implementation is part of the statement API which can be used independently before calling spirit.

Changes:

  • Added a complete diff implementation with support for columns, indexes, constraints, table options, and partitioning
  • Enhanced the parser to capture more detailed schema information (partition expressions, index column details, foreign key actions)
  • Added extensive test coverage with 985 lines of table-driven tests covering various schema migration scenarios

Reviewed changes

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

Show a summary per file
File Description
pkg/statement/diff.go New file implementing the complete diff functionality with ~1400 lines of comprehensive logic
pkg/statement/diff_test.go New file with extensive table-driven tests covering all diff scenarios
pkg/statement/parse_create_table.go Enhanced parser to extract full expressions for partitions, binary type detection, charset/collation, foreign key actions, and index column details
pkg/statement/parse_create_table_test.go Updated tests to reflect improved partition expression parsing and added comprehensive binary type tests
go.mod Updated testify from v1.10.0 to v1.11.1
go.sum Updated checksums for testify dependency

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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated no new comments.


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

@morgo morgo requested a review from aparajon February 22, 2026 22:41
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.


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

@morgo morgo enabled auto-merge February 23, 2026 19:11
@morgo morgo merged commit 547ea41 into block:main Feb 23, 2026
9 checks passed
@morgo morgo mentioned this pull request Feb 23, 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.

3 participants