go-mysqlstack icon indicating copy to clipboard operation
go-mysqlstack copied to clipboard

How to mock a simple insert statement?

Open noahyao1024 opened this issue 2 years ago • 2 comments

Thanks you, I want to proxy some query to my own HTTP server, But it does't work on 'INSERT' while 'SELECT' is maybe perfect.

I use this piece of snippet to response, But MySQL received as a Empty query. if strings.HasPrefix(query, "insert") { testResult.InsertID = 100 testResult.RowsAffected = 1 testResult.Rows = append(make([][]sqltypes.Value, 0), testResult.Rows[0]) testResult.Rows = make([][]sqltypes.Value, 0) }

Thanks you very much

noahyao1024 avatar Jan 05 '23 08:01 noahyao1024

@BohuTANG HELP!

noahyao1024 avatar Jan 05 '23 12:01 noahyao1024

The codes are no longer maintained, but I'm sure they work. I guess the issue is building the testResult, you can try to build it like this:

https://github.com/xelabs/go-mysqlstack/blob/master/driver/client_test.go#L24-L27

BohuTANG avatar Jan 05 '23 14:01 BohuTANG