Fix DoubleColon cast skipping AT TIME ZONE #1266 (#1267)

This commit is contained in:
Dmitry Bugakov 2024-05-11 21:26:57 +02:00 committed by GitHub
parent 036a4120b4
commit 49d178477e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 58 additions and 10 deletions

View file

@ -7022,6 +7022,27 @@ fn parse_set_variable() {
one_statement_parses_to("SET SOMETHING TO '1'", "SET SOMETHING = '1'");
}
#[test]
fn parse_double_colon_cast_at_timezone() {
let sql = "SELECT '2001-01-01T00:00:00.000Z'::TIMESTAMP AT TIME ZONE 'Europe/Brussels' FROM t";
let select = verified_only_select(sql);
assert_eq!(
&Expr::AtTimeZone {
timestamp: Box::new(Expr::Cast {
kind: CastKind::DoubleColon,
expr: Box::new(Expr::Value(Value::SingleQuotedString(
"2001-01-01T00:00:00.000Z".to_string()
),)),
data_type: DataType::Timestamp(None, TimezoneInfo::None),
format: None
}),
time_zone: "Europe/Brussels".to_string()
},
expr_from_projection(only(&select.projection)),
);
}
#[test]
fn parse_set_time_zone() {
match verified_stmt("SET TIMEZONE = 'UTC'") {