Skip to content

Delegate database engines to sqlglot-go - #111

Closed
moshloop wants to merge 3 commits into
mainfrom
refactor/delegate-to-sqlglot-dmbczhs9lfqg
Closed

moshloop wants to merge 3 commits into
mainfrom
refactor/delegate-to-sqlglot-dmbczhs9lfqg

Conversation

@moshloop

Copy link
Copy Markdown
Member

What

  • Move the SQL Server differ, type mapping, routine parsing, and migration planner into github.com/flanksource/sqlglot-go/migrate/atlas/sqlserver.
  • Replace commons-db SQL inspection, capabilities, target parsing, catalog readers, and migration engines with typed sqlglot-go shims.
  • Execute reviewed SQL Server artifacts transactionally.

Why

  • Keeps the pure diff and plan logic in one shared package. The commons-db driver retains catalog inspection, HCL loading, connections, locks, transactions, and statement execution.

Notes

  • Breaking: atlas/sqlserver no longer exports ParseType, FormatType, ParseRoutine, CreateOrAlter, DefaultDiff, DefaultPlan, and the attribute types. Callers must import the sqlglot-go package instead.
  • CreateOrAlter now accepts ALTER PROCEDURE/FUNCTION definitions and rewrites them to CREATE OR ALTER.
  • Planning a view without a T-SQL definition now fails with a routine-specific error.
  • Pins sqlglot-go to v1.0.4-0.20261022121445-328654b54c0a (feat: standalone inspect and migrate sqlglot-go#10). Merge the sqlglot dependency PR first.
  • Validation: all 10 tracked database Gavel fixture gates pass, per the commit message.

The SQL Server differ, type mapping, routine parsing and migration planner now live in
github.com/flanksource/sqlglot-go/migrate/atlas/sqlserver. The commons-db driver keeps catalog
inspection, HCL loading, connections, locks, transactions and statement execution, and delegates
the pure diff and plan logic to that package.

The exported helpers that moved (ParseType, FormatType, ParseRoutine, CreateOrAlter, DefaultDiff,
DefaultPlan and the attribute types such as Identity, Clustered and Definition) are removed from
atlas/sqlserver. Callers must import the sqlglot-go package instead.

BREAKING CHANGE: atlas/sqlserver no longer exports ParseType, FormatType, ParseRoutine,
CreateOrAlter, DefaultDiff, DefaultPlan, Identity, DefaultConstraint, Clustered, IndexInclude,
IndexPredicate, UniqueConstraint, Definition and Routine. CreateOrAlter now accepts ALTER
PROCEDURE/FUNCTION definitions and rewrites them to CREATE OR ALTER, and planning a view without
a T-SQL definition fails with a routine-specific error.
Claude-Session-Id: 01a15eea-9e79-7161-890a-03eac0c66cf1
Replace commons-db SQL inspection, capabilities, custom Atlas SQL Server runtime, target parsing, catalog readers, and migration engines with typed sqlglot-go shims. Preserve existing public options and types, caller-owned handles, PostgreSQL bundle behavior, and catalog cache metadata. Move implementation-owned tests with the engine and retain consumer compatibility coverage.

Pin sqlglot-go v1.0.4-0.20261022121445-328654b54c0a, the published commit from flanksource/sqlglot-go#10, so the new packages resolve without a local replacement. Merge the sqlglot dependency PR first.

Validation: all 10 tracked database Gavel fixture gates pass, including SQLite API/cache compatibility, existing PostgreSQL bundle/view-dependency migrations, and the standalone native engine suite. Unrelated Git, query, and connection changes are excluded from this commit.

Gavel-Issue-Id: e5e4b378-75e4-4291-9c72-585d138a7cef
@coderabbitai

coderabbitai Bot commented Oct 22, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

Gavel summary

Source Pass Fail Skip Duration
e2e 121 0 0 481ms

Totals: 121 passed · 0 failed · 0 skipped · 481ms

View full results

@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedgolang/​github.com/​flanksource/​sqlglot-go@​v1.0.4-0.20261022121445-328654b54c0a90100100100100

View full report

@github-actions

Copy link
Copy Markdown
Contributor

Gavel crashed before producing results

Exit code: 1
Error: test execution failed: cannot map go test packages [github.com/flanksource/commons-db/pkg/kube/labels [github.com/flanksource/commons-db/pkg/kube/labels.test]] to requested paths []

Full gavel.log, JSON stub, and HTML stub are in the workflow artifact.

View full results

@moshloop moshloop closed this Oct 22, 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.

1 participant