Skip to content

Commit

Permalink
fix zero not parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
NoBypass committed Apr 4, 2024
1 parent 0fd005a commit 4b8e92d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 0 additions & 3 deletions parse_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ func parseParam(arg any, idx int) (map[string]any, error) {
if arg == nil {
return nil, nil
}
if reflect.ValueOf(arg).IsZero() {
return nil, nil
}
m := make(map[string]any, 1)

switch arg.(type) {
Expand Down
11 changes: 11 additions & 0 deletions parse_params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ func Test_parseQuery(t *testing.T) {
assert.NoError(t, err)
m.AssertCalled(t, "Query", query, map[string]any{"1": 1})
})
t.Run("Query wuth zero value parameter", func(t *testing.T) {
m := new(MockQueryAgent)
db := &DB{m}
query := "SELECT * FROM test WHERE id = $1;"

m.On("Query", mock.Anything, mock.Anything).Return(emptyResponse, nil)
_, err := db.Exec(query, 0)

assert.NoError(t, err)
m.AssertCalled(t, "Query", query, map[string]any{"1": 0})
})
t.Run("Query with multiple slice parameters", func(t *testing.T) {
m := new(MockQueryAgent)
db := &DB{m}
Expand Down

0 comments on commit 4b8e92d

Please sign in to comment.