vitessdriver: send string for binary result values#19542
Conversation
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #19542 +/- ##
===========================================
+ Coverage 69.67% 78.26% +8.58%
===========================================
Files 1614 5 -1609
Lines 216793 483 -216310
===========================================
- Hits 151044 378 -150666
+ Misses 65749 105 -65644
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
📝 Documentation updates detected! Updated existing suggestion: Remove changelog entry for vitessdriver binary-to-string change (reverted) Tip: Whenever you leave a comment tagged |
arthurschreiber
left a comment
There was a problem hiding this comment.
Can you add a test case for this? Maybe a unit test and an integration level test would be good.
05b84a8 to
c14a3fc
Compare
dbussink
left a comment
There was a problem hiding this comment.
You'll also will need to fix the DCO here.
| case []byte: | ||
| if t == nil { | ||
| return sqltypes.NullBindVariable, nil | ||
| } |
There was a problem hiding this comment.
I wasn't quite sure what the right behavior here was. There are three outcomes:
NullBindVariable: what is happening here, which is an untyped null- Typed
NULLasVARBINARY: this is the only one I'm fairly confident that we don't want, as it is likely to trigger a similar error for json values - Typed
NULLasVARCHAR: this maintains the spirit of the string conversion here, but may be unnecessary
Is there any reason to choose a typed null over what is currently happening? This has to happen before the string conversion because string isn't nullable natively
c14a3fc to
2a9fb0f
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2a9fb0f8c6
ℹ️ 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".
| if !reflect.DeepEqual(bv, tcase.out) { | ||
| t.Fatalf("BuildBindVariable(%v) = %#v, want %#v", tcase.in, bv, tcase.out) | ||
| } |
There was a problem hiding this comment.
Nit, but we should use require in new tests.
There was a problem hiding this comment.
changed and I added a commit migrating the rest of the vitessdriver tests to require
Signed-off-by: Derek Perkins <derek@nozzle.io>
Signed-off-by: Derek Perkins <derek@nozzle.io>
2a9fb0f to
594b11c
Compare
There was a problem hiding this comment.
Pull request overview
Updates vitessdriver parameter binding to avoid sending []byte inputs as VARBINARY (which can trigger MySQL JSON charset errors), while reverting the earlier behavior change that affected how binary-typed result values are returned to Go callers.
Changes:
- Revert
ToNativebehavior so binary result values remain[]byte(undoing the prior “return string for binary results” approach). - Update
BuildBindVariableto convert[]byteinputs intoVARCHARbind variables (andnil []byteintoNULL) before sending to Vitess. - Refactor several vitessdriver tests to use
testify/requireassertions and add targeted tests forBuildBindVariable.
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 |
|---|---|
| go/vt/vitessdriver/convert.go | Moves the “bytes->string” conversion to bind-var construction (inputs), and removes the binary special-case from result conversion (outputs). |
| go/vt/vitessdriver/convert_test.go | Updates ToNative expectations for binary types and adds new coverage for BuildBindVariable. |
| go/vt/vitessdriver/driver_test.go | Converts many assertions to require and improves subtest isolation with t.Run. |
| go/vt/vitessdriver/rows_test.go | Converts comparisons to require and removes now-unneeded mismatch logging helper. |
| go/vt/vitessdriver/streaming_rows_test.go | Converts comparisons/error checks to require and removes unused imports. |
Signed-off-by: Derek Perkins <derek@nozzle.io>
Signed-off-by: Derek Perkins <derek@nozzle.io>
Signed-off-by: Derek Perkins <derek@nozzle.io> Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
Description
Apologies, my prior PR in #19527 did the string conversion the wrong direction, coming out of Vitess vs going into Vitess. This reverts that change and does a similar conversion before building the bind variable.
Related Issue(s)
Checklist
Deployment Notes
AI Disclosure
None