✨Fix api/v1/users/condition end point can not handle filter with Chinese #130
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
GPT 5 prompt
I guess due to chinese_name is utf8 input cause above error, can you propose a fix in sponge framework?
example payload
error log
2025-09-03 09:00:54.318 INFO middleware/logging.go:230 >>>> {"code": 200, "method": "POST", "url": "/api/v1/users/condition", "time_us": 4108, "size": 1362, "body": "{\"code\":0,\"msg\":\"ok\",\"data\":{\"users\":{\"id\":1,\"email\":\"[email protected]\",\"encryptedPassword\":\"$2a$11$pc3izhrvG9kYisahCXTavuaOWKafPEUsXpeAXCUDkgUADao7lIZpi\",\"resetPasswordToken\":\"\",\"resetPasswordSentAt\":null,\"rememberCreatedAt\":\"2025-04-15T07:20:07+08:00\",\"signInCount\":17845,\"currentS ...... ", "request_id": "K1KyxAQ43T"} 2025-09-03 09:01:11.201 INFO middleware/logging.go:199 <<<< {"method": "POST", "url": "/api/v1/users/condition", "size": 68, "body": "{\"columns\":[{\"name\":\"chinese_name\",\"exp\":\"like\",\"value\":\"\\u8fc7%\"}]}", "request_id": "Erq8Ap6sdv"} 2025-09-03 09:01:11.201 WARN glog/glog.go:94 Gorm msg {"error": "Error 3988 (HY000): Conversion from collation utf8mb3_general_ci into utf8mb4_0900_ai_ci impossible for parameter", "sql": "SELECT * FROM `users` WHERE chinese_name LIKE 'è\ufffd\ufffd%' ORDER BY `users`.`id` LIMIT 1", "rows": 0, "ms": 0.473583, "file_line": "dao/users.go:339", "request_id": "Erq8Ap6sdv"} 2025-09-03 09:01:11.201 ERROR handler/users.go:307 GetByCondition error {"error": "Error 3988 (HY000): Conversion from collation utf8mb3_general_ci into utf8mb4_0900_ai_ci impossible for parameter", "form": {"columns":[{"name":"chinese_name","exp":"like","value":"过%","logic":""}]}, "request_id": "Erq8Ap6sdv"} test-user-server/internal/handler.(*usersHandler).GetByCondition /Users/guochunzhong/git/user_server-web-http/internal/handler/users.go:307 github.com/gin-gonic/gin.(*Context).Next /Users/guochunzhong/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:185 github.com/go-dev-frame/sponge/pkg/gin/middleware/metrics.Metrics.func1 /Users/guochunzhong/git/oss/sponge/pkg/gin/middleware/metrics/metrics.go:121 github.com/gin-gonic/gin.(*Context).Next /Users/guochunzhong/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:185 github.com/go-dev-frame/sponge/pkg/gin/middleware.Logging.func1 /Users/guochunzhong/git/oss/sponge/pkg/gin/middleware/logging.go:214 github.com/gin-gonic/gin.(*Context).Next /Users/guochunzhong/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:185 github.com/go-dev-frame/sponge/pkg/gin/middleware.RequestID.func1 /Users/guochunzhong/git/oss/sponge/pkg/gin/middleware/requstid.go:102 github.com/gin-gonic/gin.(*Context).Next /Users/guochunzhong/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:185 github.com/gin-gonic/gin.CustomRecoveryWithWriter.func1 /Users/guochunzhong/go/pkg/mod/github.com/gin-gonic/[email protected]/recovery.go:102 github.com/gin-gonic/gin.(*Context).Next /Users/guochunzhong/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:185 github.com/gin-gonic/gin.(*Engine).handleHTTPRequest /Users/guochunzhong/go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:644 github.com/gin-gonic/gin.(*Engine).ServeHTTP /Users/guochunzhong/go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:600 net/http.serverHandler.ServeHTTP /opt/homebrew/Cellar/go/1.24.6/libexec/src/net/http/server.go:3301 net/http.(*conn).serve /opt/homebrew/Cellar/go/1.24.6/libexec/src/net/http/server.go:2102 2025-09-03 09:01:11.202 ERROR middleware/logging.go:228 >>>> {"code": 500, "method": "POST", "url": "/api/v1/users/condition", "time_us": 982, "size": 53, "body": "{\"code\":500,\"msg\":\"Internal Server Error\",\"data\":{}}", "request_id": "Erq8Ap6sdv"}