File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,9 @@ const (
19
19
20
20
// parseOperator parses a leading logical operator out of the provided string
21
21
func parseOperator (s string ) string {
22
+ if len (s ) == 0 {
23
+ return ""
24
+ }
22
25
switch s [0 ] {
23
26
case operatorLesser [0 ]: // "<"
24
27
if 1 == len (s ) {
@@ -98,13 +101,9 @@ func (c ComparativeTime) String() string {
98
101
99
102
// Parse is used to parse a query string into a ComparativeString instance
100
103
func (c * ComparativeString ) Parse (query string ) error {
101
- if len (query ) <= 2 {
102
- return errors .New ("qstring: Invalid Query" )
103
- }
104
-
105
104
c .Operator = parseOperator (query )
106
105
107
- if c .Operator != operatorDifferent && c .Operator != operatorLike && c .Operator != operatorEquals {
106
+ if len ( c . Operator ) > 0 && c .Operator != operatorDifferent && c .Operator != operatorLike && c .Operator != operatorEquals {
108
107
return errors .New (fmt .Sprintf ("qstring: Invalid operator for %T" , c ))
109
108
}
110
109
if c .Operator == operatorEquals {
@@ -128,5 +127,8 @@ func (c *ComparativeString) Parse(query string) error {
128
127
// String returns this ComparativeString instance in the form of the query
129
128
// parameter that it came in on
130
129
func (c ComparativeString ) String () string {
130
+ if c .Operator == operatorEquals {
131
+ c .Operator = ""
132
+ }
131
133
return fmt .Sprintf ("%s%s" , c .Operator , c .Str )
132
134
}
You can’t perform that action at this time.
0 commit comments