File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -144,6 +144,9 @@ func (b Select) With(args ...stmt.WithQuery) Select {
144144
145145// Where adds WHERE clauses.
146146func (b Select ) Where (condition stmt.Expression ) Select {
147+ if condition == nil {
148+ panic ("loukoum: condition must be not nil" )
149+ }
147150 if b .query .Where .IsEmpty () {
148151 b .query .Where = stmt .NewWhere (condition )
149152 return b
@@ -154,6 +157,9 @@ func (b Select) Where(condition stmt.Expression) Select {
154157
155158// And adds AND WHERE conditions.
156159func (b Select ) And (condition stmt.Expression ) Select {
160+ if condition == nil {
161+ panic ("loukoum: condition must be not nil" )
162+ }
157163 b .query .Where = b .query .Where .And (condition )
158164 return b
159165}
Original file line number Diff line number Diff line change 44 "fmt"
55 "testing"
66
7+ "github.com/stretchr/testify/require"
78 loukoum "github.com/ulule/loukoum/v3"
89 "github.com/ulule/loukoum/v3/builder"
910 "github.com/ulule/loukoum/v3/stmt"
@@ -1630,3 +1631,21 @@ func TestSelect_Extra(t *testing.T) {
16301631 },
16311632 })
16321633}
1634+
1635+ func TestSelect_NilCondition (t * testing.T ) {
1636+ is := require .New (t )
1637+ is .Panics (func () {
1638+ var nilcond stmt.Expression
1639+ loukoum .Select ("col" ).
1640+ From ("table" ).
1641+ Where (loukoum .Condition ("col" ).Equal ("value" )).
1642+ And (nilcond )
1643+ })
1644+
1645+ is .Panics (func () {
1646+ var nilcond stmt.Expression
1647+ loukoum .Select ("col" ).
1648+ From ("table" ).
1649+ Where (nilcond )
1650+ })
1651+ }
You can’t perform that action at this time.
0 commit comments