Skip to content

Commit

Permalink
Merge #95625
Browse files Browse the repository at this point in the history
95625: builtins: fix json_build_object for tsvector/tsquery r=jordanlewis a=jordanlewis

Previously, json_build_object would return an internal error when encountering tsvector/tsquery types. This is now corrected.

Updates #87322

Epic: CRDB-22357
Release note: None (no released version with this issue)

Co-authored-by: Jordan Lewis <[email protected]>
  • Loading branch information
craig[bot] and jordanlewis committed Jan 21, 2023
2 parents 2861a4e + a6c96c1 commit 6f87274
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/json_builtins
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,11 @@ SELECT json_build_object('{"a":1,"b":2}'::JSON, 3)
query error pq: json_build_object\(\): key value must be scalar, not array, tuple, or json
SELECT json_build_object('{1,2,3}'::int[], 3)

query T
SELECT json_build_object('a'::tsvector, 1, 'b'::tsquery, 2)
----
{"'a'": 1, "'b'": 2}

query T
SELECT json_extract_path('{"a": 1}', 'a')
----
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/sem/builtins/builtins.go
Original file line number Diff line number Diff line change
Expand Up @@ -10118,7 +10118,7 @@ func asJSONBuildObjectKey(
*tree.DDecimal, *tree.DEnum, *tree.DFloat, *tree.DGeography,
*tree.DGeometry, *tree.DIPAddr, *tree.DInt, *tree.DInterval, *tree.DOid,
*tree.DOidWrapper, *tree.DTime, *tree.DTimeTZ, *tree.DTimestamp,
*tree.DUuid, *tree.DVoid:
*tree.DTSQuery, *tree.DTSVector, *tree.DUuid, *tree.DVoid:
return tree.AsStringWithFlags(d, tree.FmtBareStrings), nil
default:
return "", errors.AssertionFailedf("unexpected type %T for key value", d)
Expand Down

0 comments on commit 6f87274

Please sign in to comment.