我的数据库和模型有所有相关字段。我想发送查询到数据库,但我遇到了这个错误。:
error: error occurred while decoding column 0: expected value at line 13 column 5
--> src/handler.rs:98:16
|
98 | let user = sqlx::queryas!(
| __^
99 | | User,
100 | | "SELECT * FROM users WHERE pan = $1",
101 | | body.pan
102 | | )
| |__^
|
= note: this error originates in the macro $crate::sqlx_macros::expand_query which comes from the expansion of the macro sqlx::query_as (in Nightly builds, run with -Z macro-backtrace for more info)
字符串
我正在使用sqlx与Axum和postgres。
编码
let user = sqlx::query_as!(
User,
"SELECT * FROM users WHERE pan = $1",
body.pan
)
.fetch_optional(&data.db)
.await
[dependencies]
argon2 = "0.5.0"
axum = "0.6.18"
axum-extra = { version = "0.7.4", features = ["cookie"] }
chrono = { version = "0.4.26", features = ["serde"] }
dotenv = "0.15.0"
sqlx = { version = "0.7.0", features = ["runtime-async-std-native-tls", "postgres", "chrono", "uuid"] }
time = "0.3.22"
tokio = { version = "1.29.1", features = ["full"] }
uuid = { version = "1.4.0", features = ["serde", "v4"] }
的数据
1条答案
按热度按时间laawzig21#
当我更新到新版本(0.7.x)SQLx时,我也得到了这个无用的错误。
当我降级到0.6.3版本时,这些错误再次变得有用。
我还没有做任何工作,试图找出这两个版本之间的变化。