diff --git a/filterparser.go b/filterparser.go index f0d55c51..fd075106 100644 --- a/filterparser.go +++ b/filterparser.go @@ -334,6 +334,10 @@ func (p *FilterParser) parseOperatorAndValue() (parserToken, interface{}, error) func (p *FilterParser) makeFilter(key string, operator parserToken, value interface{}) (*Filter, error) { + if strings.HasPrefix(key, "$") { + return nil, fmt.Errorf("could not start a parameter with $. Found %s", key) + } + filter := NewFilterComposer() // Create filter diff --git a/filterparser_test.go b/filterparser_test.go index 7e857f11..807295a6 100644 --- a/filterparser_test.go +++ b/filterparser_test.go @@ -235,16 +235,16 @@ func TestParser_Keys(t *testing.T) { Convey("Given the expression is a tag like '$key'", t, func() { parser := NewFilterParser("$key == value") - expectedFilter := NewFilterComposer().WithKey("$key").Equals("value").Done() + // expectedFilter := NewFilterComposer().WithKey("$key").Equals("value").Done() Convey("When I run Parse", func() { filter, err := parser.Parse() - Convey("Then there should be no error and the filter should as expected", func() { - So(err, ShouldEqual, nil) - So(filter, ShouldNotEqual, nil) - So(filter.String(), ShouldEqual, expectedFilter.String()) + Convey("Then there should have an error", func() { + So(err, ShouldNotEqual, nil) + So(err.Error(), ShouldContainSubstring, "could not start a parameter with $") + So(filter, ShouldEqual, nil) }) }) })