Problem
date_trunc currently accepts any value type and always claims to return that same Rust type:
pub fn date_trunc<T>(part: impl IntoExpr<String>, value: impl IntoExpr<T>) -> Expr<T>
This allows invalid calls such as date_trunc("day", integer_column) to compile. DATE and TIME inputs can also receive an incorrect output type after PostgreSQL overload resolution or implicit casts.
The precision argument is fixed to required String, so a nullable precision expression is rejected even though PostgreSQL returns NULL when it is NULL.
Expected behavior
- Support the direct PostgreSQL input/result pairs:
TIMESTAMP → TIMESTAMP
TIMESTAMPTZ → TIMESTAMPTZ
INTERVAL → INTERVAL
- Preserve optional output when the precision or temporal value is nullable.
- Reject unrelated inputs at compile time.
- Reject
DATE and TIME unless dbkit emits an explicit, stable cast with the correct output type.
- Cover required/nullable combinations for all supported base types.
- Decide whether to expose PostgreSQL's timestamptz timezone argument as part of the same typed contract.
PostgreSQL date_trunc signatures
Problem
date_trunccurrently accepts any value type and always claims to return that same Rust type:This allows invalid calls such as
date_trunc("day", integer_column)to compile.DATEandTIMEinputs can also receive an incorrect output type after PostgreSQL overload resolution or implicit casts.The precision argument is fixed to required
String, so a nullable precision expression is rejected even though PostgreSQL returns NULL when it is NULL.Expected behavior
TIMESTAMP→TIMESTAMPTIMESTAMPTZ→TIMESTAMPTZINTERVAL→INTERVALDATEandTIMEunless dbkit emits an explicit, stable cast with the correct output type.PostgreSQL
date_truncsignatures