Skip to content

Fix code example in the jsonb_populate_recordset() function docs#5134

Open
duffuniverse wants to merge 1 commit into
neondatabase:mainfrom
duffuniverse:fix-code-example-in-jsonb-populate-recordset-func-docs
Open

Fix code example in the jsonb_populate_recordset() function docs#5134
duffuniverse wants to merge 1 commit into
neondatabase:mainfrom
duffuniverse:fix-code-example-in-jsonb-populate-recordset-func-docs

Conversation

@duffuniverse

Copy link
Copy Markdown
Contributor

Detail

  • Fix a code example.
  • Fix a type name.

@vercel

vercel Bot commented Jun 23, 2026

Copy link
Copy Markdown

@duffuniverse is attempting to deploy a commit to the neondatabase Team on Vercel.

A member of the Team first needs to authorize it.

'id', id, 'name', name, 'age', age, 'salary',
salary
))
))::jsonb

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original query doesn't work 🔴 :

dvdrental=# SELECT
  jsonb_populate_recordset(
    null :: employees,
    json_agg(jsonb_build_object(
      'id', id, 'name', name, 'age', age, 'salary',
      salary
    ))
  ) AS employees
FROM
  employees;

ERROR:  function jsonb_populate_recordset(employees, json) does not exist
LINE 2:   jsonb_populate_recordset(
          ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

Using the suggestion from the hints 🟢 :

dvdrental=# SELECT
  jsonb_populate_recordset(
    null :: employees,
    json_agg(jsonb_build_object(
      'id', id, 'name', name, 'age', age, 'salary',
      salary
    ))::jsonb
  ) AS employees
FROM
  employees;

         employees         
---------------------------
 (1,"John Doe",25,70000)
 (2,"Jane Smith",22,80000)
(2 rows)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant