Skip to content

Commit

Permalink
time: DateTimeProxy without backend
Browse files Browse the repository at this point in the history
With the time feature enabled and no active database backend
compilation fails because no sql_type is specified for DateTimeProxy.

This is fixed by only deriving AsExpression for DateTimeProxy when a
database backend is active.
  • Loading branch information
surban committed Aug 5, 2023
1 parent c5a9f7b commit a3a4a7e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion diesel/src/type_impls/date_and_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,12 @@ mod time {
#[cfg_attr(feature = "mysql_backend", diesel(sql_type = crate::sql_types::Datetime))]
struct NaiveDateTimeProxy(PrimitiveDateTime);

#[derive(AsExpression, FromSqlRow)]
#[derive(FromSqlRow)]
#[diesel(foreign_derive)]
#[cfg_attr(
any(feature = "postgres_backend", feature = "sqlite", feature = "mysql_backend"),
derive(AsExpression)
)]
#[cfg_attr(
feature = "postgres_backend",
diesel(sql_type = crate::sql_types::Timestamptz)
Expand Down

0 comments on commit a3a4a7e

Please sign in to comment.