Skip to content

Commit c5914f4

Browse files
authored
Merge pull request #2887 from dolthub/nicktobey/json-length
Correct the behavior of passing a JSON object into the JSON_LENGTH function.
2 parents 909b08b + 1dd6a95 commit c5914f4

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

sql/expression/function/json/json_length.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func (j *JsonLength) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
117117
return nil, nil
118118
}
119119
return len(v), nil
120-
case map[any]any:
120+
case map[string]interface{}:
121121
return len(v), nil
122122
default:
123123
return 1, nil

sql/expression/function/json/jsontests/json_length_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ func TestJsonLength(t *testing.T) {
7474
row: sql.Row{`{"a": 1}`},
7575
exp: 1,
7676
},
77-
77+
{
78+
f: f1,
79+
row: sql.Row{`{"a": 1, "b": 2}`},
80+
exp: 2,
81+
},
7882
{
7983
f: f2,
8084
row: sql.Row{`{"a": [1, false]}`, nil},

0 commit comments

Comments
 (0)