mirror of
https://github.com/hanzoai/sqlbuilder.git
synced 2026-10-01 00:37:42 +00:00
Merge pull request #204 from edznux-dd/nil-pointer-deref
[bugfix] Nil pointer deref
This commit is contained in:
@@ -417,3 +417,8 @@ func ExampleSelectBuilder_LateralAs() {
|
||||
// Output:
|
||||
// SELECT salesperson.name, max_sale.amount, max_sale.customer_name FROM salesperson, LATERAL (SELECT amount, customer_name FROM all_sales WHERE all_sales.salesperson_id = salesperson.id ORDER BY amount DESC LIMIT ?) AS max_sale
|
||||
}
|
||||
|
||||
func TestNilPointerWhere(t *testing.T) {
|
||||
NewSelectBuilder().SQL("$0").Build()
|
||||
NewSelectBuilder().SQL("$0").BuildWithFlavor(DefaultFlavor)
|
||||
}
|
||||
|
||||
+4
-1
@@ -60,7 +60,7 @@ var _ Builder = new(whereClauseProxy)
|
||||
|
||||
// BuildWithFlavor builds a WHERE clause with the specified flavor and initial arguments.
|
||||
func (wc *WhereClause) BuildWithFlavor(flavor Flavor, initialArg ...interface{}) (sql string, args []interface{}) {
|
||||
if len(wc.clauses) == 0 {
|
||||
if wc == nil || len(wc.clauses) == 0 {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
@@ -128,6 +128,9 @@ func (wc *WhereClause) AddWhereExpr(args *Args, andExpr ...string) *WhereClause
|
||||
|
||||
// AddWhereClause adds all clauses in the whereClause to the wc.
|
||||
func (wc *WhereClause) AddWhereClause(whereClause *WhereClause) *WhereClause {
|
||||
if wc == nil {
|
||||
return nil
|
||||
}
|
||||
if whereClause == nil {
|
||||
return wc
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user