VOL-3190 throw error message when filter or order on struct
Change-Id: If15983350d3f1a6fd21e5bfcec33ae57808cc31f
diff --git a/pkg/order/order.go b/pkg/order/order.go
index bcf097b..09ef1fc 100644
--- a/pkg/order/order.go
+++ b/pkg/order/order.go
@@ -110,6 +110,16 @@
if !field.IsValid() {
return field, fmt.Errorf("Failed to find field %s while sorting", name)
}
+
+ // we might have a pointer to a struct at this time, so dereference it
+ if field.Kind() == reflect.Ptr {
+ field = reflect.Indirect(field)
+ }
+
+ if field.Kind() == reflect.Struct {
+ return val, fmt.Errorf("Cannot sort on a field that is a struct")
+ }
+
return field, nil
}