Skip to content

Commit 1295b1c

Browse files
author
James Cor
committed
fix json_extract panic
1 parent b02d6d5 commit 1295b1c

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

enginetest/queries/queries.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9854,6 +9854,12 @@ from typestable`,
98549854
{"NULL"},
98559855
},
98569856
},
9857+
{
9858+
Query: `SELECT json_type(json_extract('{"a": null}', null));`,
9859+
Expected: []sql.Row{
9860+
{"NULL"},
9861+
},
9862+
},
98579863
{
98589864
Query: "SELECT json_type(cast(cast('2001-01-01 12:34:56.123456' as datetime) as json));",
98599865
Expected: []sql.Row{

sql/expression/function/json/json_extract.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ func (j *JSONExtract) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
101101
if err != nil {
102102
return nil, err
103103
}
104+
105+
if path == nil {
106+
continue
107+
}
104108

105109
results[i], err = types.LookupJSONValue(searchable, path.(string))
106110
if err != nil {

0 commit comments

Comments
 (0)