Skip to content

Commit 8a50642

Browse files
author
James Cor
committed
return null immediately
1 parent 1295b1c commit 8a50642

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

enginetest/queries/queries.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9855,7 +9855,13 @@ from typestable`,
98559855
},
98569856
},
98579857
{
9858-
Query: `SELECT json_type(json_extract('{"a": null}', null));`,
9858+
Query: `SELECT json_type(json_extract('{"a": 123}', null));`,
9859+
Expected: []sql.Row{
9860+
{"NULL"},
9861+
},
9862+
},
9863+
{
9864+
Query: `SELECT json_type(json_extract('{"a": 123}', '$.a', null));`,
98599865
Expected: []sql.Row{
98609866
{"NULL"},
98619867
},

sql/expression/function/json/json_extract.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ func (j *JSONExtract) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
101101
if err != nil {
102102
return nil, err
103103
}
104-
104+
105105
if path == nil {
106-
continue
106+
return nil, nil
107107
}
108108

109109
results[i], err = types.LookupJSONValue(searchable, path.(string))

0 commit comments

Comments
 (0)