Skip to content

Commit

Permalink
fix: use replacewith for sort items if available
Browse files Browse the repository at this point in the history
  • Loading branch information
tauslim committed Mar 21, 2024
1 parent 3a8d1fd commit ee66c97
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,14 @@ func (p *Parser) validateSpecialOps(r *RqlRootNode) error {
}

func (p *Parser) validateSort(sortItems []Sort) error {
for _, s := range sortItems {
for i, s := range sortItems {
f, ok := p.fields[s.By]
if !ok || !f.Sortable {
return fmt.Errorf("field %s is not sortable", s.By)
}
if f.ReplaceWith != "" {
sortItems[i].By = f.ReplaceWith
}
}
return nil
}
Expand Down

0 comments on commit ee66c97

Please sign in to comment.