If I insert an Option<sqlx::types::Json<Struct>>
sqlx writes the text null
in DB instead of mark that field as NULL
#3294
Labels
I thought the problem was me and my code and so I tried to reproduce the problem with your code in examples.
I only made minor changes by adding an
Option<>
to simulate my real problem.and in
migrations
:If I run it it is saved in the DB:
and instead I expect this:
Where am I doing wrong?
Minimal Reproduction
https://github.com/frederikhors/iss-sqlx-option-null
Info
"0.7.4"
"macros", "postgres", "runtime-tokio", "chrono", "uuid"
Postgres 16
Windows
rustc --version
:rustc 1.79.0 (129f3b996 2024-06-10)
I think we can also close these issues after this one (maybe):
JSON Option<> None/Null Behavior #2438
#[sqlx(json)] does not support nullable values #2849
The text was updated successfully, but these errors were encountered: