Repository navigation
docs: commit the batch in the database/sql Sessions example and restore its full example - #2187
Open
VanshajPoonia wants to merge 2 commits into
Open
VanshajPoonia wants to merge 2 commits into
VanshajPoonia wants to merge 2 commits into
Conversation
The snippet appended 10 rows to a batch and read the table without a Commit, so the batch was never sent and the SELECT returned no rows. Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
The Sessions docs link to examples/std/session.go, which was removed in ClickHouse#1258. The example commits its batch and returns an error if it does not read the 10 rows back, so TestStdSession fails if the snippet breaks again. Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
VanshajPoonia
requested review from
a team,
kavirajk and
polyglotAI-bot
as code owners
November 30, 2026 06:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2185.
The "Sessions" snippet in
docs/database-sql-api.mdxadds 10 rows to a batch fromconn.Begin()and then reads the table. It does not callCommit, so the driver never sends the batch and theSELECTreturns no rows. The snippet now callsscope.Commit()before theSELECT, as the "Batch insert" section of the same page says.The "Full Example" link under the snippet points to
examples/std/session.go, which #1258 removed. This PR restores that file with the commit and addsTestStdSessionback toexamples/std/main_test.go. The example returns an error if it does not read the 10 rows back, so the test fails if the snippet breaks again. #1258 gives no reason for the removal. If you prefer to keep the example out, I can remove the link instead.Checklist
go test ./examples/std/ -run TestStdSession -count=20passes 20 of 20 on ClickHouse 26.11.5.8 (latest), and each run printsrow: col1=0torow: col1=9. Without theCommit, the test fails withexpected 10 rows, got 0.go test ./examples/std/passes.Note
Low Risk
Documentation and example/test-only changes; no driver or runtime behavior is modified.
Overview
Fixes the Sessions snippet in
docs/database-sql-api.mdxby callingscope.Commit()after the batchedINSERTand beforeSELECT, matching the Batch insert guidance so HTTP session batch data is actually sent.Restores
examples/std/session.go(linked from the docs) with the same flow, explicit commit, and an assertion that all 10 rows are read back. AddsTestStdSessioninexamples/std/main_test.goso the example stays correct.Reviewed by Cursor Bugbot for commit e4e1191. Bugbot is set up for automated code reviews on this repo. Configure here.