When querying with struct, the released GORM will only query with non-zero fields, that means if the field’s value is 0,'', false or other zero values, it won’t be used to build query conditions. And if I want to include zero values in the query conditions, I must use a map, which will include all key-values as query conditions.
But it is obvious that querying with structure is simpler and more convenient than querying with map query(e.g. My field names may be modified, and I don't want to modify the map in every query statement). So could GORM to support the freedom to choose whether to query zero fields when querying by struct? And adding a parameter to let the user choose whether to query the zero fields, it is compatible with the existing query method.
More simply, conveniently and uniformly to build query conditions.
Related Issues
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: 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 ✨