使用Debug打印时Group Where失效

我的链式调用如下,使用了Group Where来编写复杂的sql err := db.Where( db.Where("channel = ?", constants.CouponChannelShop). Or("channel = ?", constants.CouponChannelCash), // 现金 ). Where("id in ?", couponIds). Count(&count).Error Gorm 使用Debug打印时Group Where失效 然而我在使用Debug是出现了问题,Count似乎是忽略了Group Where err := db.Debug().Where( db.Where("channel = ?", constants.CouponChannelShop). Or("channel = ?", constants.CouponChannelCash), // 现金 ). Where("id in ?", couponIds). Count(&count).Error 20240105-154142

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: iTanken

这样试一下:

db = db.Debug()
err := db.Where( db.Where("channel = ?", constants.CouponChannelShop). Or("channel = ?", constants.CouponChannelCash), // 现金 ). Where("id in ?", couponIds). Count(&count).Error

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: Madou-Shinni

这样试一下:

go db = db.Debug() err := db.Where( db.Where("channel = ?", constants.CouponChannelShop). Or("channel = ?", constants.CouponChannelCash), // 现金 ). Where("id in ?", couponIds). Count(&count).Error

也许这看起来不怎么遍历,但这确实是一种有效的方式,他解决了Debug Group Where消失的问题