Skip to content

querying JSON field #738

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

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 4 replies

You must be logged in to vote
2 replies
@deelienardy

@zzhaolei

Answer selected by kyleconroy

You must be logged in to vote
2 replies
@acaloiaro

@coolaj86

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

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