diff --git a/util/sqlgen/group_by.go b/util/sqlgen/group_by.go index 03762a58f56e849c54734d44f0f6c24be734e1aa..fe8ed3f34c7d0b05e343432a8561de96a3ae9656 100644 --- a/util/sqlgen/group_by.go +++ b/util/sqlgen/group_by.go @@ -17,7 +17,9 @@ type groupByT struct { // Hash returns a unique identifier. func (g *GroupBy) Hash() string { if g.hash == "" { - g.hash = fmt.Sprintf(`GroupBy(%s)`, g.Columns.Hash()) + if g.Columns != nil { + g.hash = fmt.Sprintf(`GroupBy(%s)`, g.Columns.Hash()) + } } return g.hash } diff --git a/util/sqlgen/order_by.go b/util/sqlgen/order_by.go index edaa78f0acdf95cc5ac838f0cd05f79686643fd3..d437cde386ba7df348deff2f302b73e088f378fe 100644 --- a/util/sqlgen/order_by.go +++ b/util/sqlgen/order_by.go @@ -35,7 +35,7 @@ type SortColumns struct { // OrderBy represents an ORDER BY clause. type OrderBy struct { - SortColumns *SortColumns + SortColumns Fragment hash string } @@ -115,7 +115,9 @@ func (s *SortColumns) Compile(layout *Template) (compiled string) { // Hash returns a unique identifier. func (s *OrderBy) Hash() string { if s.hash == "" { - s.hash = `OrderBy(` + s.SortColumns.Hash() + `)` + if s.SortColumns != nil { + s.hash = `OrderBy(` + s.SortColumns.Hash() + `)` + } } return s.hash }