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

Expose MysqlParameterConverter as alternative to DefaultParameterConverter that lacks uint64 support #1637

Open
matejsp opened this issue Oct 17, 2024 · 0 comments

Comments

@matejsp
Copy link

matejsp commented Oct 17, 2024

Issue description

We are trying to use sql.Null[uint64]{}. While it works for mysql database the check fails for sqlMock, because it uses default converter that is not aware of uint64.

sqlMock uses DefaultParameterConverter and it fails with uint64.
https://github.com/DATA-DOG/go-sqlmock/blob/master/sqlmock.go#L112-L114

Now DefaultParameterConverter is public from go/sql package.
https://github.com/golang/go/blob/master/src/database/sql/driver/types.go#L213C2-L213C47

However sqlmock supports providing different parameter converter.
https://github.com/DATA-DOG/go-sqlmock/blob/master/options.go#L10-L15

Basically if you are willing to expose it as MysqlParameterConverter:
https://github.com/go-sql-driver/mysql/blob/master/statement.go#L135

Example code

db, sqlMock, err := sqlmock.New(sqlmock.ValueConverterOption(MysqlParameterConverter{}))

Error log

sql: converting argument $7 type: non-Value type uint64 returned from Value

Configuration

Driver version (or git SHA): 1.8.1

Go version: 1.23.2

Server version: MySQL 8.0, sqlmock 1.5.2

Server OS: MacOSX

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

No branches or pull requests

1 participant