Skip to content

Enhance diff command with normalized output and compatibility handling#56

Open
zacateras wants to merge 6 commits intomainfrom
feature/closing-compatibility-gap
Open

Enhance diff command with normalized output and compatibility handling#56
zacateras wants to merge 6 commits intomainfrom
feature/closing-compatibility-gap

Conversation

@zacateras
Copy link
Copy Markdown
Member

This pull request introduces several enhancements and compatibility improvements to the SQL schema comparison and scripting tool. The most significant changes include new normalization and compatibility rules for diffing scripts, improved diff output readability, expanded scripting of object permissions and options, and more precise discovery and exclusion of certain system objects. Additionally, new CLI options and behaviors have been documented to aid debugging and provide more control over output.

Diff and Comparison Normalization Improvements:

  • Added normalization to treat equivalent TableData scripts as compatible when single-row INSERT column lists and value tuples are reordered consistently, and improved handling of contiguous INSERT statement ordering. [1] [2] [3]
  • Improved compatibility for legacy Table, UserDefinedType, and constraint formatting, including handling of inline constraints and permission statement ordering. [1] [2] [3]
  • Extended normalization to treat empty and whitespace-only separator lines as compatible, ignore leading SSMS-generated banner comments, and consider omitted terminal GO batches as compatible. [1] [2] [3]

Diff Output and CLI Enhancements:

  • Added --normalized-diff option to sqlct diff for rendering comparison-normalized diff text for debugging, while preserving readable diff output by default. [1] [2] [3] [4]
  • Improved diff rendering to preserve structural boundaries for tables and table-valued types, so changes are pinpointed rather than collapsing entire statements into one changed line. [1] [2]

Scripting and Discovery Updates:

  • Excluded SSMS database-diagram support stored procedures from discovery and scripting. [1] [2]
  • Scripted database-level permissions granted directly to Role and User principals, including support for loginless users (CREATE USER ... WITHOUT LOGIN). [1] [2]
  • Scripted TYPE:: permissions for scalar and table-valued UserDefinedType objects.

Table and Index Option Scripting:

  • Persisted key and index storage options such as fill factor, pad index, duplicate-key handling, and row/page locking are now scripted when they differ from defaults. The order of emitted WITH options is now strictly specified. [1] [2] [3]

Documentation and Spec Updates:

  • Updated CLI documentation and specifications to reflect new options, behaviors, and normalization rules. [1] [2] [3] [4] [5]

These changes collectively improve compatibility detection, script readability, and user control over diff output, while ensuring more accurate and deterministic schema scripting.

- Introduced a new command line option `--normalized-diff` in `DiffCommandSettings` to control the normalization of diff output.
- Updated `RunDiff` method in `ISyncCommandService` and its implementation to accept a new parameter for normalized diff.
- Modified the `SyncCommandService` to handle normalized diff logic in the diff generation process.
- Enhanced the `BuildUnifiedDiff` method to support normalized diff rendering.
- Updated tests to verify the behavior of the new normalized diff feature.
…e permissions

- Implement tests to recognize and filter excluded stored procedures related to database diagrams in SqlServerIntrospectorTests.
- Enhance SqlServerScripterTests with functionality to script roles and users, including permissions for user-defined types.
- Introduce unified diff tests in SyncCommandServiceTests to handle permission order differences and suppress irrelevant changes for user-defined types and tables.
- Ensure consistent handling of user and role permissions in unified diffs, including suppression of terminal GO statements.
@zacateras zacateras marked this pull request as ready for review April 10, 2026 13:37
@zacateras zacateras linked an issue Apr 10, 2026 that may be closed by this pull request
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.

Improve scripting compatibility

1 participant