Skip to content

Can't query Json field #3008

Answered by alper
alper asked this question in Q&A
Jan 2, 2022 · 2 comments · 5 replies
Discussion options

You must be logged in to vote

OK. I found out what the issue was.

Just like the input value from the documentation is a serde_json::Value, the return value from the query is also a serde_json::Value. I have no clue what diesel::sql_types::Json is for then.

Also, we don't get the struct back that's in models but a vector of tuples instead. (Why have a model?)

So the working code is:

let results = gmaps_locations
    .select((id, place_id, data))
    .load::<(i32, String, serde_json::Value)>(&connection)
    .expect("Erorr loading locations");

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
5 replies
@weiznich
Comment options

@alper
Comment options

@weiznich
Comment options

@alper
Comment options

@alper
Comment options

Answer selected by alper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants