“sql: expected 1 destination arguments in Scan” Error in Golang QueryRow with JSONB Data
The issue arises when attempting to use db.QueryRow to retrieve data from a JSONB column and storing the results in multiple destination arguments. However, the query returns only one field, leading to the "expected 1 destination arguments in Scan" error.
To resolve this issue, there are several approaches:
err := db.QueryRow("SELECT data->>'id', data->>'type', data->>'title' FROM message WHERE data->>'id'=$1"
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3