The Wayback Machine - https://web.archive.org/web/20201020112435/https://github.com/go-sql-driver/mysql/pull/690
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement NamedValueChecker for mysqlConn #690

Merged
merged 1 commit into from Nov 16, 2017

Conversation

@pushrax
Copy link
Contributor

@pushrax pushrax commented Oct 20, 2017

Fixes #342

Calls to Exec for non-prepared statements with uint64 arguments having high-bits set are currently broken. The typical "uint64 values with high bit set are not supported" error is returned.

_, err := db.Exec("INSERT INTO test (id) VALUES (?)", uint64(0xffffffffffffffff))

Now that the NamedValueChecker interface is in Go, this can be solved by implementing it for mysqlConn. The implementation is based on defaultCheckNamedValue.

I also included changes from golang/go@d7c0de9

cc @shuhaowu @daniellaniyo @hkdsun @fw42

@pushrax
Copy link
Contributor Author

@pushrax pushrax commented Oct 20, 2017

This breaks the build for Go 1.7 and earlier, so I moved the implementation into the go1.8 file.

@pushrax pushrax force-pushed the pushrax:named-value-checker branch from 0ce6231 to 5e3001f Oct 21, 2017
@fw42
Copy link

@fw42 fw42 commented Oct 23, 2017

This breaks the build for Go 1.7 and earlier, so I moved the implementation into the go1.8 file.

I assume that means that your binary will only include the fix to this issue if you compile with a newer version of Go? Compiling it with older Go versions will give you an unfixed version (same as before)?

@@ -157,6 +157,16 @@ func (c converter) ConvertValue(v interface{}) (driver.Value, error) {
return int64(u64), nil
case reflect.Float32, reflect.Float64:
return rv.Float(), nil
case reflect.Bool:

This comment has been minimized.

@fw42

fw42 Oct 23, 2017

The changes in this file affect all versions (not just 1.8). Can you explain what this does? In particular what does this do to 1.7 and lower?

This comment has been minimized.

@fw42

fw42 Oct 23, 2017

Oh nvm I just saw that this is from golang/go@d7c0de9

@fw42
fw42 approved these changes Oct 23, 2017
Copy link

@fw42 fw42 left a comment

LGTM as far as I can tell 👍

@pushrax
Copy link
Contributor Author

@pushrax pushrax commented Oct 23, 2017

Compiling it with older Go versions will give you an unfixed version (same as before)?

Right, the API for making the fix possible is not available in older Go versions.

@julienschmidt
Copy link
Member

@julienschmidt julienschmidt commented Oct 27, 2017

The general approach looks fine to me 👍 .
Bonus points, if you implement further tests (e.g. for string #623), as the NamedValueChecker is used also for other values than uint64 with high bit set.

@julienschmidt julienschmidt added this to the v1.4 milestone Oct 27, 2017
@pushrax pushrax force-pushed the pushrax:named-value-checker branch 2 times, most recently from 8f556d3 to 4214b36 Oct 30, 2017
@pushrax
Copy link
Contributor Author

@pushrax pushrax commented Nov 9, 2017

Copy link
Member

@julienschmidt julienschmidt left a comment

Seems good.
I'd like to merge #623 first though. The author of that PR is responsive again.

@julienschmidt
Copy link
Member

@julienschmidt julienschmidt commented Nov 15, 2017

#623 is merged. This PR now needs a rebase on (or merge with) the current master.

* Also add conversions for additional types in ConvertValue
  ref golang/go@d7c0de9
@pushrax pushrax force-pushed the pushrax:named-value-checker branch from 4214b36 to e281d84 Nov 16, 2017
@pushrax
Copy link
Contributor Author

@pushrax pushrax commented Nov 16, 2017

Done.

@julienschmidt julienschmidt merged commit 78d399c into go-sql-driver:master Nov 16, 2017
3 checks passed
3 checks passed
WIP ready for review
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.3%) to 77.535%
Details
@julienschmidt
Copy link
Member

@julienschmidt julienschmidt commented Nov 16, 2017

Thanks for contributing!

randomjunk added a commit to randomjunk/mysql that referenced this pull request Nov 16, 2017
…rnally

Added a test that Valuer types are handled correctly. This test fails without the fix.

CheckNamedValue code was included recently and breaks existing applications:
go-sql-driver#690

Reported in:
go-sql-driver#708
randomjunk added a commit to randomjunk/mysql that referenced this pull request Nov 16, 2017
…rnally

Added a test that Valuer types are handled correctly. This test fails without the fix.

CheckNamedValue code was included recently and breaks existing applications:
go-sql-driver#690

Reported in:
go-sql-driver#708
bLamarche413 pushed a commit to bLamarche413/mysql that referenced this pull request Mar 23, 2018
* Also add conversions for additional types in ConvertValue
  ref golang/go@d7c0de9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.