This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Type mixup when deserializing from DB despite successful compilation #4494
Labels
You can continue the conversation there. Go to discussion →
Setup
Versions
rustc 1.82.0 (f6e511eec 2024-10-15)
2.2.7
Feature Flags
Problem Description
What are you trying to accomplish?
This is a reduced part of my application code, where I try to represent an optional left-join in a query struct. So having
Option<OtherQueryableTableStruct>
as a field in a one Queryable table struct. Then in the case of actually performing this left join (first case in test case which passes), we select the fields of the other joined table in a nested tuple. But when the left join is not performed and we only want the first table isolated, we just passsql::<Nullable<(the column types of the joined table)>>("NULL")
.In production I noticed error
{"code":500,"message":"Error deserializing field 'exported': Unsupported JSONB encoding version"}
(exported
being a bool both in Diesel schema, queryable struct, postgres table).After reducing to reproducible example, it change slightly but still shows that it mixes up the types.
What is the expected output?
I expect it to be able to query the joined table into the struct.
The result would be that
extra_field
isSome
What is the actual output?
The first query succeeds but the second query fails:
It may seem like the nested tuple makes Diesel mix up which type it asks for which column? Or am I doing something wrong?
But I would have expected Diesel to catch type discrepancies at compile time.
Steps to reproduce
Cargo.toml
main.rs
Output:
Checklist
closed if this is not the case)
serde_json
andchrono
in this case but probably without as well)The text was updated successfully, but these errors were encountered: