Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upInsertable and chrono::DateTime<Utc> does not work #1541
Comments
This comment has been minimized.
|
|
This comment has been minimized.
vityafx
commented
Feb 6, 2018
|
Can we have a list of all available types for use with diesel? And also with all backends (pg, sqlite, mysql, and so on)? This would be very useful. |
This comment has been minimized.
vityafx
commented
Feb 6, 2018
|
Tried to change to error[E0277]: the trait bound `chrono::NaiveDateTime: diesel::Expression` is not satisfied
--> models.rs:6:35
|
6 | #[derive(Debug, Clone, Queryable, Insertable)]
| ^^^^^^^^^^ the trait `diesel::Expression` is not implemented for `chrono::NaiveDateTime`
|
= note: required because of the requirements on the impl of `diesel::Expression` for `&chrono::NaiveDateTime`
= note: required because of the requirements on the impl of `diesel::expression::AsExpression<diesel::sql_types::Text>` for `&chrono::NaiveDateTime`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) |
This comment has been minimized.
|
You're probably missing the |
This comment has been minimized.
vityafx
commented
Feb 6, 2018
|
@Eijebong r2d2-diesel = "1"
r2d2 = "0.8"
[dependencies.diesel]
version = "1"
features = ["sqlite", "chrono"]
[dependencies.chrono]
version = "0.4"
features = ["serde"] |
This comment has been minimized.
vityafx
commented
Feb 6, 2018
|
The diesel migration sql script: -- Your SQL goes here
CREATE TABLE punishments (
user_id INTEGER NOT NULL,
server_id INTEGER NOT NULL,
start_time TEXT NOT NULL,
duration TEXT NOT NULL,
reason TEXT NOT NULL,
PRIMARY KEY (user_id, server_id)
) |
This comment has been minimized.
|
Ha, that's why, you have to tell diesel this is a datetime. Either change the type of |
This comment has been minimized.
vityafx
commented
Feb 6, 2018
•
|
@Eijebong I thought that was the problem! :) But I looked over the documentation of diesel and the code for the |
This comment has been minimized.
vityafx
commented
Feb 6, 2018
•
|
Checked again - there is nothing like |
This comment has been minimized.
|
http://docs.diesel.rs/diesel/sql_types/struct.Timestamp.html You'll need to call your type |
This comment has been minimized.
vityafx
commented
Feb 7, 2018
|
Thank you. I somehow thought that the |
vityafx
closed this
Feb 7, 2018
This comment has been minimized.
|
|
vityafx commentedFeb 5, 2018
•
edited
I am trying to make my model insertable but I have a error which I don't know how to solve.
I use:
sqlitediesel = "1"