Skip to content

Commit 8684450

Browse files
committed
chore: align with parse_date_str
1 parent 72781fc commit 8684450

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

rust/cubesql/pg-srv/src/values/timestamp.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,14 @@ impl FromProtocolValue for TimestampValue {
158158
.or_else(|_| NaiveDateTime::parse_from_str(as_str, "%Y-%m-%d %H:%M:%S%.f"))
159159
.or_else(|_| NaiveDateTime::parse_from_str(as_str, "%Y-%m-%dT%H:%M:%S"))
160160
.or_else(|_| NaiveDateTime::parse_from_str(as_str, "%Y-%m-%dT%H:%M:%S%.f"))
161+
// PostgreSQL supports more formats aligned with parse_date_str
162+
.or_else(|_| NaiveDateTime::parse_from_str(as_str, "%Y-%m-%dT%H:%M:%S%.fZ"))
163+
.or_else(|_| {
164+
NaiveDate::parse_from_str(as_str, "%Y-%m-%d").map(|date| {
165+
date.and_hms_opt(0, 0, 0)
166+
.expect("Unable to set time to 00:00:00")
167+
})
168+
})
161169
.map_err(|err| ProtocolError::ErrorResponse {
162170
source: ErrorResponse::error(
163171
ErrorCode::ProtocolViolation,

0 commit comments

Comments
 (0)