From 30283daf08abbcc331b1ed1e588007afcc4f77be Mon Sep 17 00:00:00 2001 From: THOTHADRI RAJESH VIDYASANKAR Date: Tue, 2 Apr 2024 13:43:23 -0700 Subject: [PATCH] Update query.go --- query.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/query.go b/query.go index 47d3796..2e584da 100644 --- a/query.go +++ b/query.go @@ -43,6 +43,10 @@ func (f QueryMatcherFunc) Match(expectedSQL, actualSQL string) error { // used by sqlmock. It parses expectedSQL to a regular // expression and attempts to match actualSQL. var QueryMatcherRegexp QueryMatcher = QueryMatcherFunc(func(expectedSQL, actualSQL string) error { + if actual != "" and expect == "" { + return fmt.Errorf("expectedSQL can't be empty") + } + expect := stripQuery(expectedSQL) actual := stripQuery(actualSQL) re, err := regexp.Compile(expect)