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

fix: use native ScanType from driver and enhance RowBuffer to understand more types #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mechinn
Copy link

@mechinn mechinn commented Aug 22, 2023

the go mysql driver provides a very good mapping of database types to go types by doing reflect.New(tp.ScanType()).Interface() directly instead of manually mapping all integers to sql.NullInt64, strings to sql.NullString, etc. with reflectColumnType()

It seems the reason the ColumnType was being interpreted differently was to account for mocking VARCHAR columns that were expected to have rows with NULL values that could not be scanned to a simple string, the fix was to change the unit tests to have the sampleValue be a sql.NullString{} instead of a simple string.

This allows database connections that have ParseTime = true to correctly dump DATETIME columns.

Also wrapped SET NAMES and SET character_set_client with mysql version comments like mysqldump does.

@mechinn
Copy link
Author

mechinn commented Aug 30, 2023

added a workaround for go-sql-driver/mysql#1424 not being in a released version yet by adding reflectColumnType() back just to handle string/binary types correctly

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

Successfully merging this pull request may close these issues.

None yet

1 participant