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 feff673
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 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,16 @@ 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 feff673

Please sign in to comment.