Skip to content

Patch float with trailing zero for JSON and add useFloatWithTrailingZero flag #1038

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

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

Conversation

chenhuiyeh
Copy link

@chenhuiyeh chenhuiyeh commented May 21, 2025

This pull request enables support for MySQL 8+ for retaining trailing zeros in floating-point numbers in JSON format. This is achieved through the addition of the useFloatWithTrailingZero setting option within the go-mysql library. Note this only works with MySQL version 8 onwards.

A patch addressing this feature was initially applied in ghostferry PR #368. This current PR seeks to integrate these updates into the upstream codebase to extend functionality for users and projects relying on this library.

This change is part of the broader initiative referenced in ghostferry PR #384.

@chenhuiyeh chenhuiyeh changed the title batch float with trailing zero and add a useFloatWithTrailingZero fla… patch float with trailing zero and add useFloatWithTrailingZero flag May 21, 2025
@dveeden
Copy link
Collaborator

dveeden commented May 21, 2025

It would be good to add some tests and a description or an issue link.

@chenhuiyeh chenhuiyeh changed the title patch float with trailing zero and add useFloatWithTrailingZero flag Patch float with trailing zero for JSON and add useFloatWithTrailingZero flag May 21, 2025
@chenhuiyeh chenhuiyeh force-pushed the float_with_trailing_zero branch from 814aa96 to 9d46fb3 Compare May 21, 2025 19:29
@lance6716
Copy link
Collaborator

Hi, please fix the CI. And I'll take a look after you remove the draft status of PR.

@lance6716
Copy link
Collaborator

Hi, do you need some help?

@chenhuiyeh
Copy link
Author

chenhuiyeh commented Jun 4, 2025 via email

@lance6716
Copy link
Collaborator

--- FAIL: TestSyncerSuite (18.99s)
    --- FAIL: TestSyncerSuite/TestFloatWithTrailingZeros (0.03s)
        suite.go:87: test panicked: interface conversion: interface {} is string, not []uint8
            goroutine 52 [running]:
            runtime/debug.Stack()
            	/home/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/debug/stack.go:26 +0x67
            github.com/stretchr/testify/suite.failOnPanic(0xc0001901c0, {0xee6a00, 0xc0000a5050})
            	/home/runner/go/pkg/mod/github.com/stretchr/[email protected]/suite/suite.go:87 +0x4e
            github.com/stretchr/testify/suite.Run.func1.1()
            	/home/runner/go/pkg/mod/github.com/stretchr/[email protected]/suite/suite.go:183 +0x359
            panic({0xee6a00?, 0xc0000a5050?})
            	/home/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/panic.go:792 +0x132
            github.com/go-mysql-org/go-mysql/replication.(*testSyncerSuite).testFloatWithTrailingZerosCase(0xc000316000, 0x1)
            	/home/runner/work/go-mysql/go-mysql/replication/replication_test.go:531 +0x7af
            github.com/go-mysql-org/go-mysql/replication.(*testSyncerSuite).TestFloatWithTrailingZeros(0xc000316000)
            	/home/runner/work/go-mysql/go-mysql/replication/replication_test.go:484 +0xb2
            reflect.Value.call({0xc000318f80?, 0xc00005ef30?, 0x13?}, {0xf7f62f, 0x4}, {0xc00011fea8, 0x1, 0x1?})
            	/home/runner/go/pkg/mod/golang.org/[email protected]/src/reflect/value.go:584 +0xd4e
            reflect.Value.Call({0xc000318f80?, 0xc00005ef30?, 0x604520?}, {0xc000185ea8, 0x1, 0x1})
            	/home/runner/go/pkg/mod/golang.org/[email protected]/src/reflect/value.go:368 +0xb6
            github.com/stretchr/testify/suite.Run.func1(0xc0001901c0)
            	/home/runner/go/pkg/mod/github.com/stretchr/[email protected]/suite/suite.go:1[97](https://github.com/go-mysql-org/go-mysql/actions/runs/15448405868/job/43507909759?pr=1038#step:6:98) +0x6ee
            testing.tRunner(0xc0001901c0, 0xc00016c870)
            	/home/runner/go/pkg/mod/golang.org/[email protected]/src/testing/testing.go:1792 +0x226
            created by testing.(*T).Run in goroutine 22
            	/home/runner/go/pkg/mod/golang.org/[email protected]/src/testing/testing.go:1851 +0x8f3
FAIL

@@ -0,0 +1,403 @@
package replication
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to pull the unit tests out specifically for this feature/fix

@chenhuiyeh chenhuiyeh marked this pull request as ready for review June 5, 2025 19:20
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.

4 participants