feat: try cast timestamp types from number string (#6060)

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
This commit is contained in:
Ruihang Xia
2025-05-07 19:29:35 +08:00
committed by GitHub
parent 06126147d2
commit 60acf28f3c
3 changed files with 4 additions and 2 deletions

View File

@@ -107,6 +107,8 @@ fn parse_string_to_value(
target_unit: t.unit(),
},
)?))
} else if let Ok(ts) = i64::from_str(s.as_str()) {
Ok(Value::Timestamp(Timestamp::new(ts, t.unit())))
} else {
ParseSqlValueSnafu {
msg: format!("Failed to parse {s} to Timestamp value"),

View File

@@ -13,7 +13,7 @@ INSERT INTO integers VALUES (11, 1), (12, 2);
affected_rows: 2
-- SQLNESS PROTOCOL MYSQL
INSERT INTO integers VALUES ('13', 3), ('14', 4);
INSERT INTO integers VALUES ('13', '3'), ('14', '4');
affected_rows: 2

View File

@@ -9,7 +9,7 @@ CREATE TABLE integers (
INSERT INTO integers VALUES (11, 1), (12, 2);
-- SQLNESS PROTOCOL MYSQL
INSERT INTO integers VALUES ('13', 3), ('14', 4);
INSERT INTO integers VALUES ('13', '3'), ('14', '4');
-- SQLNESS PROTOCOL MYSQL
INSERT INTO integers VALUES ('15a', 5), ('16', 6);