Skip to content

Commit 87d61ec

Browse files
authored
Merge pull request #156974 from yuzefovich/blathers/backport-release-25.4-156691
release-25.4: sql: fix a couple of spots where we missed JSONPATH and LTREE
2 parents e59b548 + aaf18e7 commit 87d61ec

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

pkg/sql/logictest/testdata/logic_test/json_builtins

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,17 @@ SELECT to_json((1, 2, 'hello', NULL, NULL))
215215
----
216216
{"f1": 1, "f2": 2, "f3": "hello", "f4": null, "f5": null}
217217

218+
query T
219+
SELECT to_json(('$'::JSONPATH, '$.foo'::JSONPATH))
220+
----
221+
{"f1": "$", "f2": "$.\"foo\""}
222+
223+
skipif config local-mixed-25.2 local-mixed-25.3
224+
query T
225+
SELECT to_json(('foo'::LTREE, 'bar'::LTREE))
226+
----
227+
{"f1": "foo", "f2": "bar"}
228+
218229
query T
219230
SELECT to_jsonb(123::INT)
220231
----
@@ -613,6 +624,17 @@ SELECT json_build_object('a'::tsvector, 1, 'b'::tsquery, 2)
613624
----
614625
{"'a'": 1, "'b'": 2}
615626

627+
query T
628+
SELECT json_build_object('$'::JSONPATH, 1)
629+
----
630+
{"$": 1}
631+
632+
skipif config local-mixed-25.2 local-mixed-25.3
633+
query T
634+
SELECT json_build_object('foo'::LTREE, 2)
635+
----
636+
{"foo": 2}
637+
616638
query T
617639
SELECT json_extract_path('{"a": 1}', 'a')
618640
----

pkg/sql/sem/builtins/builtins.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12125,8 +12125,9 @@ func asJSONBuildObjectKey(
1212512125
), nil
1212612126
case *tree.DBitArray, *tree.DBool, *tree.DBox2D, *tree.DBytes, *tree.DDate,
1212712127
*tree.DDecimal, *tree.DEnum, *tree.DFloat, *tree.DGeography,
12128-
*tree.DGeometry, *tree.DIPAddr, *tree.DInt, *tree.DInterval, *tree.DOid,
12129-
*tree.DOidWrapper, *tree.DPGLSN, *tree.DPGVector, *tree.DTime, *tree.DTimeTZ,
12128+
*tree.DGeometry, *tree.DIPAddr, *tree.DInt, *tree.DInterval,
12129+
*tree.DJsonpath, *tree.DLTree, *tree.DOid, *tree.DOidWrapper,
12130+
*tree.DPGLSN, *tree.DPGVector, *tree.DTime, *tree.DTimeTZ,
1213012131
*tree.DTimestamp, *tree.DTSQuery, *tree.DTSVector, *tree.DUuid, *tree.DVoid:
1213112132
return tree.AsStringWithFlags(d, tree.FmtBareStrings), nil
1213212133
default:

pkg/sql/sem/tree/datum.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3877,7 +3877,7 @@ func AsJSON(
38773877
// This is RFC3339Nano, but without the TZ fields.
38783878
return json.FromString(formatTime(t.UTC(), "2006-01-02T15:04:05.999999999")), nil
38793879
case *DDate, *DUuid, *DOid, *DInterval, *DBytes, *DIPAddr, *DTime, *DTimeTZ, *DBitArray, *DBox2D,
3880-
*DTSVector, *DTSQuery, *DPGLSN, *DPGVector, *DLTree:
3880+
*DTSVector, *DTSQuery, *DPGLSN, *DPGVector, *DJsonpath, *DLTree:
38813881
return json.FromString(
38823882
AsStringWithFlags(t, FmtBareStrings, FmtDataConversionConfig(dcc), FmtLocation(loc)),
38833883
), nil

0 commit comments

Comments
 (0)