Replies: 1 comment
-
For someone who is here. This is a simple but no where mention it (Please @ me if there is a document describe it). The sqlx use the column name to comment type use chrono::{DateTime, Utc};
use sqlx::query_as;
let title = "some";
let article = query_as!(
Article,
r#"
SELECT
id,
title,
create_time AS "create_time: DateTime<Utc>"
FROM article
WHERE title LIKE "%?%"
"#
title
)
.fetch_one(db_pool)
.await?; |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using the Rust frameworks Axum and SQLx to develop a web service.
Now I've encountered a problem. My entity class is as follows:
My database table structure is:
The query is:
My Cargo configuration is:
I'm focusing on the updated_at and created_at fields. Their corresponding types are: Option<DateTime> <===> TEXT.
When using them, I get the following error:
However, according to the documentation at https://docs.rs/sqlx/latest/sqlx/sqlite/types/index.html, it states that chrono::DateTime can be converted to DATETIME (TEXT, INTEGER, REAL).

But in practice, I'm getting an error. What could be the reason for this?
Beta Was this translation helpful? Give feedback.
All reactions