🧰 The Rust SQL Toolkit. An async, pure Rust SQL crate featuring compile-time checked queries without a DSL. Supports PostgreSQL, MySQL, and SQLite.
13.15k
stars
1.24k
forks
source link
If I insert an `Option<sqlx::types::Json<Struct>>` sqlx writes the text `null` in DB instead of mark that field as `NULL` #3294
Closed
frederikhors closed 3 months ago
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):
https://github.com/launchbadge/sqlx/issues/2438
https://github.com/launchbadge/sqlx/issues/2849