Closed
Description
Hi team,
I've used sqlx with the following model:
CREATE TABLE `user` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`ctime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`mtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`is_deleted` tinyint(4) COLLATE utf8_general_ci NOT NULL DEFAULT 0,
`email` varchar(255) COLLATE utf8_general_ci NOT NULL DEFAULT '',
`name` varchar(255) COLLATE utf8_general_ci NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
KEY `ix_mtime` (`mtime`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
...
#[derive(FromRow, Serialize, Deserialize, Debug)]
pub struct User {
pub id: SqlID,
pub ctime: chrono::DateTime<Utc>,
pub mtime: chrono::DateTime<Utc>,
pub name: String,
pub email: String,
}
...
let result = sqlx::query_as("SELECT * FROM user")
.fetch_all(pool.get_ref()).await;
and it compiles with error below:
the trait `sqlx::Type<sqlx::MySql>` is not implemented for `chrono::DateTime<chrono::Local>`
If I changed to chrono::DateTime<chrono::Utc>
, it works.
config in Cargo.toml
likes below:
sqlx = { version = "0.4.2", features = [ "runtime-actix-native-tls", "mysql", "chrono" ] }
chrono = { version = "0.4.15", features = ["serde"] }
Help!
Metadata
Metadata
Assignees
Labels
No labels