Skip to content

querying JSON field #738

Answered by kyleconroy
deelienardy asked this question in Q&A
Oct 20, 2020 · 2 comments · 2 replies
Discussion options

You must be logged in to vote

The type of the address1 field on the JSON column isn't known at compile time. You're correct that the parameter type should be interface{} instead of json.RawMessage. I've created #743 to track that bug.

You probably know the type of address1, so you can always cast it to text:

-- name: FindByAddress :one
SELECT * FROM authors WHERE "metadata"->>'address1' = $1::text LIMIT 1;

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@deelienardy
Comment options

Answer selected by kyleconroy
Comment options

You must be logged in to vote
1 reply
@acaloiaro
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #738 on October 23, 2020 16:40.