go-gorm / playground

GORM Playground (Please Create PR for this project to report issues)
MIT License
91 stars 696 forks source link

COUNT does not work with multicolumn distinct #683

Open reality95 opened 10 months ago

reality95 commented 10 months ago

Explain your user case and expected results

I expect count to be equal to len(result), instead if you look at the debug logger, the distinct operation is dropped altogether for count if more than a column is provided. One single column works fine as in the documentation:

db.Model(&User{}).Distinct("name").Count(&count)