mysql example: security fix

This commit is contained in:
Gerasimos (Makis) Maropoulos 2021-12-30 19:32:20 +02:00
parent 62a1829cb9
commit 4aa93ae872
No known key found for this signature in database
GPG Key ID: 66FCC29BD385FCA6

View File

@ -115,9 +115,8 @@ func ParseListOptions(q url.Values) ListOptions {
offset, _ := strconv.ParseUint(q.Get("offset"), 10, 64)
limit, _ := strconv.ParseUint(q.Get("limit"), 10, 64)
order := q.Get("order") // empty, asc(...) or desc(...).
orderBy := q.Get("by") // e.g. price
return ListOptions{Offset: offset, Limit: limit, Order: order, OrderByColumn: orderBy}
return ListOptions{Offset: offset, Limit: limit, Order: order}
}
// List binds one or more records from the database to the "dest".
@ -130,10 +129,9 @@ func (s *Service) List(ctx context.Context, dest interface{}, opts ListOptions)
// If missing then try to set it by record info.
opts.Table = s.rec.TableName()
}
if opts.OrderByColumn == "" {
if b, ok := s.rec.(Sorted); ok {
opts.OrderByColumn = b.SortBy()
}
if b, ok := s.rec.(Sorted); ok {
opts.OrderByColumn = b.SortBy()
}
q, args := opts.BuildQuery()