Old gorm version: github.com/jinzhu/gorm v1.9.12
New gorm version: gorm.io/gorm v1.23.6
go-sql-driver : github.com/go-sql-driver/mysql v1.6.0
configuration:
dsn: %s:%s@tcp(%s:%d)/%s?charset=utf8mb4&parseTime=True
� gorm config:
First, sorry I can't build a case in the playground because I'm using an distributed data layer that cannot be deployed externally.But after my analysis of the source code, I may determine the cause of the problem, but it still needs further confirmation The application uses gorm as the orm framework, and the mysql driver connects to the proxy to process sub-table queries, and the proxy operates on the db. In the old version of the framework, the SQL placeholders will be processed and replaced locally and submitted to the proxy, but the new version of gorm will pre-submit the SQL with placeholders to the proxy under the default configuration, using the prepareStatement protocol , but because the proxy does not support prepareStatement enough, the query with the primary key fails to report an error. So does the new version of gorm have a configuration or parameter that supports SQL's placeholder preprocessing locally?
Temporary solution: The mysql connection parameter sets InterpolateParams to true to enable it
Comment From: github-actions[bot]
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking ✨
Comment From: a631807682
Is this what you need? https://github.com/go-sql-driver/mysql#interpolateparams
Comment From: github-actions[bot]
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking ✨