Gorm: Using '.Pluck()' on "select distinct" query returns empty strings

Created on 18 May 2015  路  2Comments  路  Source: go-gorm/gorm

phoneNumbers := []string{}
db.Select("DISTINCT phone_number").Where("name IN (?)", names).Find(&Client{}).Pluck("phone_number", &phoneNumbers)

...results in an array of empty strings.

Most helpful comment

Seems to work, thanks! Though it would be nice if it worked both ways. It's really easy to make this kind of mistake and it's only discovered if tests cover this.

All 2 comments

should like this?

db.Where("name IN (?)", names).Find(&Client{}).Pluck("DISTINCT phone_number", &phoneNumbers)

Seems to work, thanks! Though it would be nice if it worked both ways. It's really easy to make this kind of mistake and it's only discovered if tests cover this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Quentin-M picture Quentin-M  路  3Comments

zeropool picture zeropool  路  3Comments

corvinusy picture corvinusy  路  3Comments

satb picture satb  路  3Comments

leebrooks0 picture leebrooks0  路  3Comments