Skip to content

Commit a458e63

Browse files
committed
Add nil check before executing functions
1 parent 3be591a commit a458e63

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

whereclause.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ var _ Builder = new(whereClauseProxy)
6060

6161
// BuildWithFlavor builds a WHERE clause with the specified flavor and initial arguments.
6262
func (wc *WhereClause) BuildWithFlavor(flavor Flavor, initialArg ...interface{}) (sql string, args []interface{}) {
63-
if len(wc.clauses) == 0 {
63+
if wc == nil || len(wc.clauses) == 0 {
6464
return "", nil
6565
}
6666

@@ -128,6 +128,9 @@ func (wc *WhereClause) AddWhereExpr(args *Args, andExpr ...string) *WhereClause
128128

129129
// AddWhereClause adds all clauses in the whereClause to the wc.
130130
func (wc *WhereClause) AddWhereClause(whereClause *WhereClause) *WhereClause {
131+
if wc == nil {
132+
return nil
133+
}
131134
if whereClause == nil {
132135
return wc
133136
}

0 commit comments

Comments
 (0)