Skip to content

Commit 71a0e74

Browse files
committed
We don't need another equals in the value
1 parent 0235fb7 commit 71a0e74

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

fields.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ const (
1919

2020
// parseOperator parses a leading logical operator out of the provided string
2121
func parseOperator(s string) string {
22+
if len(s) == 0 {
23+
return ""
24+
}
2225
switch s[0] {
2326
case operatorLesser[0]: // "<"
2427
if 1 == len(s) {
@@ -98,13 +101,9 @@ func (c ComparativeTime) String() string {
98101

99102
// Parse is used to parse a query string into a ComparativeString instance
100103
func (c *ComparativeString) Parse(query string) error {
101-
if len(query) <= 2 {
102-
return errors.New("qstring: Invalid Query")
103-
}
104-
105104
c.Operator = parseOperator(query)
106105

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 {
108107
return errors.New(fmt.Sprintf("qstring: Invalid operator for %T", c))
109108
}
110109
if c.Operator == operatorEquals {
@@ -128,5 +127,8 @@ func (c *ComparativeString) Parse(query string) error {
128127
// String returns this ComparativeString instance in the form of the query
129128
// parameter that it came in on
130129
func (c ComparativeString) String() string {
130+
if c.Operator == operatorEquals {
131+
c.Operator = ""
132+
}
131133
return fmt.Sprintf("%s%s", c.Operator, c.Str)
132134
}

0 commit comments

Comments
 (0)