🐾 [Golang] XORM에서 this is incompatible with DISTINCT 에러 메시지 발생
배경
API를 돌리는데 에러 메시지가 떴다.
에러 메시지
해결방안
DISTINCT 사용하는 데 ORDER BY에 넣은 컬럼을 조회하지 않을 때 에러가 발생했다. 예를 들어서
builder := context.DB(c).Table(t.TableName()).Where("1=1").Desc("id").Select("distinct tag_id")
에러난 SQL문이다. 이 문장을 조회하는 tag_id로 order by를 하니까 에러가 해결 되었다.
builder := context.DB(c).Table(t.TableName()).Where("1=1").Desc("tag_id").Select("distinct tag_id")