1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-02 23:00:19 +00:00

Fix #1274: Add QuerySeter.Distinct()

This commit is contained in:
Pelle Johnsen
2015-07-22 18:12:57 +02:00
parent 9775e3e3a4
commit 19d82ab62c
3 changed files with 28 additions and 16 deletions

View File

@ -814,7 +814,11 @@ func (d *dbBase) ReadBatch(q dbQuerier, qs *querySet, mi *modelInfo, cond *Condi
}
}
query := fmt.Sprintf("SELECT %s FROM %s%s%s T0 %s%s%s%s", sels, Q, mi.table, Q, join, where, orderBy, limit)
sqlSelect := "SELECT"
if qs.distinct {
sqlSelect += " DISTINCT"
}
query := fmt.Sprintf("%s %s FROM %s%s%s T0 %s%s%s%s", sqlSelect, sels, Q, mi.table, Q, join, where, orderBy, limit)
d.ins.ReplaceMarks(&query)