From 5e58b094d83dedfe0ce5a1b0b35b867c914892b6 Mon Sep 17 00:00:00 2001 From: Ariel Mashraki <7413593+a8m@users.noreply.github.com> Date: Thu, 2 Jul 2020 16:34:34 +0300 Subject: [PATCH] schema/field: add Comparable method to TypeInfo (#576) --- schema/field/type.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/schema/field/type.go b/schema/field/type.go index 7016c1c6f..41d97bc39 100644 --- a/schema/field/type.go +++ b/schema/field/type.go @@ -111,6 +111,16 @@ func (t TypeInfo) ValueScanner() bool { return t.RType.implements(valueScannerType) } +// Comparable reports whether values of this type are comparable. +func (t TypeInfo) Comparable() bool { + switch t.Type { + case TypeBool, TypeTime, TypeUUID, TypeEnum, TypeString: + return true + default: + return t.Numeric() + } +} + var stringerType = reflect.TypeOf((*fmt.Stringer)(nil)).Elem() // Stringer indicates if this type implements the Stringer interface.