Skip to content

Support GO batches and database context sync - #79

Merged
GordonBeeming merged 13 commits into
mainfrom
gb/fix-query-go-database-context
Jul 13, 2026
Merged

GordonBeeming merged 13 commits into
mainfrom
gb/fix-query-go-database-context

Conversation

@GordonBeeming

@GordonBeeming GordonBeeming commented Jul 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Execute standalone GO separators as sequential SQL batches on the same connection.
  • Return the final database context and keep the query tab selector in sync after USE.
  • Cover case-insensitive batch separators without treating GO inside SQL text as a separator.

Why

The editor sent the complete script to SQL Server as one command, even though GO is a client-side separator. A successful USE changed the connection context but left the database selector stale.

User impact

Multi-batch scripts now run as expected, and the selected database follows successful context changes.

Validation

  • dotnet test sidecar/Ssmsx.Sidecar.slnx
  • dotnet format sidecar/Ssmsx.Sidecar.slnx --verify-no-changes --no-restore
  • npm run build
  • git diff --check

Summary by CodeRabbit

  • New Features
    • SQL scripts can now execute as multiple batches separated by standalone GO statements.
    • Query execution results now include database context, and it’s persisted in the corresponding query tab during streaming.
  • Bug Fixes
    • GO is recognized only as a standalone, case-insensitive separator, while being ignored inside string literals and block comments.
    • Multi-batch execution and per-batch cancellation now return consistent final results including database context.
  • Tests
    • Expanded GO splitting coverage (preserves line feeds, rejects unsupported repeat counts above Int32.MaxValue).

Copilot AI review requested due to automatic review settings July 13, 2026 16:03
@coderabbitai

coderabbitai Bot commented Jul 13, 2026 •

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

QueryExecutor now executes GO-separated SQL batches independently while preserving streaming and result-set behavior. Query results include database context, which is propagated through payload types and stored on completed query tabs.

Changes

Query batching and execution

Layer / File(s) Summary
GO batch splitting and execution
sidecar/src/Ssmsx.Core/Query/QueryExecutor.cs, sidecar/tests/Ssmsx.Core.Tests/Query/QueryExecutorTests.cs
SQL is split on standalone, case-insensitive GO separators, each batch uses its own command and reader, and splitting tests cover quoted/commented tokens, line-feed preservation, and oversized repeat counts.
Database result contract
sidecar/src/Ssmsx.Protocol/Messages/QueryMessages.cs, sidecar/src/Ssmsx.Core/Query/QueryExecutor.cs
QueryExecuteResult serializes an optional database value, populated on final and cancellation results.
Database state propagation
src/features/query/types.ts, src/features/query/store/queryStore.ts
Query payloads accept database context, and streaming handlers store the received database value on the matching tab.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant QueryExecutor
  participant SqlCommand
  participant SqlDataReader
  participant QueryStore
  participant QueryTab
  QueryExecutor->>QueryExecutor: Split SQL into GO-separated batches
  QueryExecutor->>SqlCommand: Create one command per batch
  SqlCommand->>SqlDataReader: Execute batch and return reader
  QueryExecutor->>SqlDataReader: Stream rows and advance result sets
  QueryExecutor->>QueryStore: Emit database context in query payload
  QueryStore->>QueryTab: Update database field
Loading

Suggested reviewers: copilot

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly reflects the main changes: GO batch execution and syncing database context.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch gb/fix-query-go-database-context

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

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces SQL batch splitting using a GO separator regex in QueryExecutor and updates the frontend to track and update the active database context per tab. The review feedback suggests compiling the regex for better performance, checking the cancellation token within the batch loop, and optimizing the frontend state updates to prevent unnecessary re-renders. Additionally, the reviewer notes that regex-based splitting may incorrectly split inside multi-line strings or comments, and points out that the database context could become stale on the frontend if a multi-batch query fails.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread sidecar/src/Ssmsx.Core/Query/QueryExecutor.cs
Comment thread sidecar/src/Ssmsx.Core/Query/QueryExecutor.cs Outdated
Comment thread sidecar/src/Ssmsx.Core/Query/QueryExecutor.cs
Comment thread sidecar/src/Ssmsx.Core/Query/QueryExecutor.cs Outdated
Comment thread src/features/query/store/queryStore.ts Outdated

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 PR updates the query execution pipeline to support client-side GO batch separators (executed sequentially on the same SQL connection) and to propagate the final database context back to the frontend so the query tab’s database selector stays in sync after successful USE statements.

Changes:

  • Split incoming SQL scripts into multiple batches using GO as a standalone separator and execute each batch sequentially on one connection.
  • Include the final Database context in the query completion payload and update the active tab’s database accordingly.
  • Add unit coverage for case-insensitive standalone GO separators and avoiding splits when GO appears as normal SQL text.

Reviewed changes

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

Show a summary per file
File Description
src/features/query/types.ts Extends streamed query payload shape to include an optional final database context.
src/features/query/store/queryStore.ts Updates the query tab’s selected database when a completion payload includes database.
sidecar/tests/Ssmsx.Core.Tests/Query/QueryExecutorTests.cs Adds a unit test validating basic GO batch splitting behavior.
sidecar/src/Ssmsx.Protocol/Messages/QueryMessages.cs Adds database to the JSON-serialized query result payload.
sidecar/src/Ssmsx.Core/Query/QueryExecutor.cs Implements batch splitting/execution and returns the final connection database context.

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

Comment thread sidecar/src/Ssmsx.Core/Query/QueryExecutor.cs Outdated
Copilot AI review requested due to automatic review settings July 13, 2026 16:08

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 36a55f9ad4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidecar/src/Ssmsx.Core/Query/QueryExecutor.cs Outdated
@GordonBeeming

Copy link
Copy Markdown
Owner Author

@codex review

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

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

Comment thread sidecar/src/Ssmsx.Core/Query/QueryExecutor.cs Outdated
Comment thread sidecar/tests/Ssmsx.Core.Tests/Query/QueryExecutorTests.cs
Copilot AI review requested due to automatic review settings July 13, 2026 16:11
@GordonBeeming

Copy link
Copy Markdown
Owner Author

@codex review

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

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

Comment thread sidecar/src/Ssmsx.Core/Query/QueryExecutor.cs Outdated
Comment thread sidecar/src/Ssmsx.Core/Query/QueryExecutor.cs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eedce52d0c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidecar/src/Ssmsx.Core/Query/QueryExecutor.cs
Copilot AI review requested due to automatic review settings July 13, 2026 16:16
@GordonBeeming

Copy link
Copy Markdown
Owner Author

@codex review

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

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

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: e6e59c0880

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copilot AI review requested due to automatic review settings July 13, 2026 16:27
@GordonBeeming

Copy link
Copy Markdown
Owner Author

@codex review

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

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

Copilot AI review requested due to automatic review settings July 13, 2026 17:27
@GordonBeeming

Copy link
Copy Markdown
Owner Author

@codex review

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

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

Comment thread sidecar/src/Ssmsx.Core/Query/QueryExecutor.cs
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: ce1c54f3de

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copilot AI review requested due to automatic review settings July 13, 2026 17:34
@GordonBeeming

Copy link
Copy Markdown
Owner Author

@codex review

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

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

Comment thread sidecar/src/Ssmsx.Core/Query/QueryExecutor.cs
Copilot AI review requested due to automatic review settings July 13, 2026 17:40
@GordonBeeming

Copy link
Copy Markdown
Owner Author

@codex review

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

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

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a06d7f6ea2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/features/query/store/queryStore.ts Outdated
Copilot AI review requested due to automatic review settings July 13, 2026 18:12
@GordonBeeming

Copy link
Copy Markdown
Owner Author

@codex review

@GordonBeeming

Copy link
Copy Markdown
Owner Author

@codex review

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

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

Copilot AI review requested due to automatic review settings July 13, 2026 18:16
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 3ca935be37

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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

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

@GordonBeeming
GordonBeeming merged commit 4db6474 into main Jul 13, 2026
8 checks passed
@GordonBeeming
GordonBeeming deleted the gb/fix-query-go-database-context branch July 13, 2026 18:33
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.

2 participants