Skip to content

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

Open
@matejsp

Description

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions