Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit834fce5

Browse files
committed
Improve error message with JSON_SERIALIZE()
The error message introduced in3c633f3 can share the same format stringwith an existing message used for JSON(), reducing the translationeffort.Author: Kyotaro HoriguchiDiscussion:https://postgr.es/m/20220708.154135.2123613118233840495.horikyota.ntt@gmail.comBackpatch-through: 15
1 parentb2b6c1b commit834fce5

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

‎src/backend/parser/parse_expr.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4587,8 +4587,9 @@ transformJsonSerializeExpr(ParseState *pstate, JsonSerializeExpr *expr)
45874587
if (typcategory!=TYPCATEGORY_STRING)
45884588
ereport(ERROR,
45894589
(errcode(ERRCODE_DATATYPE_MISMATCH),
4590-
errmsg("cannot use RETURNING type %s in JSON_SERIALIZE",
4591-
format_type_be(returning->typid)),
4590+
errmsg("cannot use RETURNING type %s in %s",
4591+
format_type_be(returning->typid),
4592+
"JSON_SERIALIZE()"),
45924593
errhint("Try returning a string type or bytea")));
45934594
}
45944595
}

‎src/test/regress/expected/sqljson.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ SELECT pg_typeof(JSON_SERIALIZE(NULL));
316316

317317
-- only string types or bytea allowed
318318
SELECT JSON_SERIALIZE('{ "a" : 1 } ' RETURNING jsonb);
319-
ERROR: cannot use RETURNING type jsonb in JSON_SERIALIZE
319+
ERROR: cannot use RETURNING type jsonb in JSON_SERIALIZE()
320320
HINT: Try returning a string type or bytea
321321
EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_SERIALIZE('{}');
322322
QUERY PLAN

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp