Skip to content

fix(sql): warn when dolt_checkout used as single -q statement#11045

Open
superShen0916 wants to merge 3 commits into
dolthub:mainfrom
superShen0916:fix/warn-dolt-checkout-single-statement
Open

fix(sql): warn when dolt_checkout used as single -q statement#11045
superShen0916 wants to merge 3 commits into
dolthub:mainfrom
superShen0916:fix/warn-dolt-checkout-single-statement

Conversation

@superShen0916

@superShen0916 superShen0916 commented May 14, 2026

Copy link
Copy Markdown

Summary

Fixes #6876 - When dolt sql -q "call dolt_checkout('branch');" is run as a single statement, the branch change does not persist because each -q invocation uses its own session. This PR adds a warning to help users understand this behavior.

Changes

  • go/cmd/dolt/commands/sql.go: Added warning in queryMode() when query contains dolt_checkout

When 'dolt sql -q "call dolt_checkout(...)"' is run as a single
statement, the branch change does not persist because each -q
invocation uses its own session.

Print a warning to help users understand this behavior.

Fixes dolthub#6876

Signed-off-by: shenpeng.sp0916 <shenpeng.sp0916@bytedance.com>

@macneale4 macneale4 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.

Thanks for the contribution! Please address the feedback and add a bats tests in the sql.bats file to verify that the warning shows once per invocation. Thanks again!

Comment thread go/cmd/dolt/commands/sql.go
shenpeng.sp0916 and others added 2 commits June 11, 2026 12:53
Use sync.Once so the warning is emitted at most once across all -q
invocations. Move the regression test from sql-checkout.bats into
sql.bats per review feedback, and cover the multiple -q case.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Warn users about running dolt sql -q "call dolt_checkout(...);"

3 participants