diff --git a/bindparam.go b/bindparam.go index 7906f53..cd2fdd5 100644 --- a/bindparam.go +++ b/bindparam.go @@ -508,7 +508,7 @@ func BindQueryParameterWithOptions(style string, explode bool, required bool, pa } else { err = bindSplitPartsToDestinationArray(parts, output) } - case reflect.Struct: + case reflect.Struct, reflect.Map: // Some struct types (e.g. types.Date, time.Time) are scalar values // that should be bound from a single string, not decomposed as // key-value objects. Detect these via the Binder and diff --git a/bindparam_test.go b/bindparam_test.go index a18fcbd..5b06543 100644 --- a/bindparam_test.go +++ b/bindparam_test.go @@ -542,6 +542,21 @@ func TestBindQueryParameter(t *testing.T) { assert.Equal(t, types.Date{Time: time.Date(2023, 6, 15, 0, 0, 0, 0, time.UTC)}, *params.StartDate) }) + t.Run("map_form_no_explode_optional", func(t *testing.T) { + want := map[string]string{ + "foo": "bar", + "bim": "baz", + } + queryParams := url.Values{ + "tags": {"foo,bar,bim,baz"}, + } + var got map[string]string + err := BindQueryParameter("form", false, false, "tags", queryParams, &got) + assert.NoError(t, err) + require.NotNil(t, got) + assert.Equal(t, want, got) + }) + t.Run("optional", func(t *testing.T) { queryParams := url.Values{ "time": {"2020-12-09T16:09:53+00:00"},