Skip to content

Commit 8d18c3d

Browse files
authored
runtimes/core: support PValue::DateTime in date columns (#1853)
1 parent 3e75caa commit 8d18c3d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

runtimes/core/src/sqldb/val.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,13 @@ impl ToSql for PValue {
212212
}
213213
}
214214
},
215-
PValue::DateTime(dt) => dt.to_sql(ty, out),
215+
PValue::DateTime(dt) => match *ty {
216+
Type::DATE => dt.naive_utc().date().to_sql(ty, out),
217+
Type::TIMESTAMP => dt.naive_utc().to_sql(ty, out),
218+
Type::TIMESTAMPTZ => dt.to_sql(ty, out),
219+
Type::TEXT | Type::VARCHAR => dt.to_rfc3339().to_sql(ty, out),
220+
_ => Err(format!("unsupported type for DateTime: {}", ty).into()),
221+
},
216222
PValue::Array(arr) => arr.to_sql(ty, out),
217223
PValue::Object(_) => {
218224
Err(format!("object not supported for column of type {}", ty).into())

0 commit comments

Comments
 (0)