From c00a317e8f150802d37c56142a2ffbd044bae551 Mon Sep 17 00:00:00 2001 From: shellyln Date: Wed, 8 Jan 2025 18:29:26 +0900 Subject: [PATCH] [FIX] If the logical operator contained uppercase letters, production rule failed. --- soql/parser/core/helpers.go | 4 +++- soql/parser/parser_test.go | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/soql/parser/core/helpers.go b/soql/parser/core/helpers.go index 156f7c9..0a55646 100644 --- a/soql/parser/core/helpers.go +++ b/soql/parser/core/helpers.go @@ -1,6 +1,8 @@ package core import ( + "strings" + . "github.com/shellyln/takenoco/base" objparser "github.com/shellyln/takenoco/object" ) @@ -31,7 +33,7 @@ func makeOpMatcher(className string, ops []string) func(c interface{}) bool { } val := ast.Value.(string) for _, op := range ops { - if op == val { + if strings.EqualFold(op, val) { return true } } diff --git a/soql/parser/parser_test.go b/soql/parser/parser_test.go index d384e29..c02529d 100644 --- a/soql/parser/parser_test.go +++ b/soql/parser/parser_test.go @@ -91,6 +91,18 @@ func TestParse(t *testing.T) { want: nil, wantErr: false, dbgBreak: true, + }, { + name: "Fix bug (2025-01-08) #1", + args: args{s: `SELECT Id FROM Contact WHERE LastName = 'bar' or (Name = 'bar' and LastName = 'foo')`}, + want: nil, + wantErr: false, + dbgBreak: true, + }, { + name: "Fix bug (2025-01-08) #2", + args: args{s: `SELECT Id FROM Contact WHERE LastName = 'bar' OR (Name = 'bar' AND LastName = 'foo')`}, + want: nil, + wantErr: false, + dbgBreak: true, }} for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {