Add span for Expr::TypedString (#1919)

This commit is contained in:
feral-dot-io 2025-07-03 16:24:51 +00:00 committed by GitHub
parent be2d2f14e7
commit 9020385c02
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 155 additions and 47 deletions

View file

@ -5851,7 +5851,10 @@ fn parse_literal_date() {
assert_eq!(
&Expr::TypedString {
data_type: DataType::Date,
value: Value::SingleQuotedString("1999-01-01".into()),
value: ValueWithSpan {
value: Value::SingleQuotedString("1999-01-01".into()),
span: Span::empty(),
}
},
expr_from_projection(only(&select.projection)),
);
@ -5864,7 +5867,10 @@ fn parse_literal_time() {
assert_eq!(
&Expr::TypedString {
data_type: DataType::Time(None, TimezoneInfo::None),
value: Value::SingleQuotedString("01:23:34".into()),
value: ValueWithSpan {
value: Value::SingleQuotedString("01:23:34".into()),
span: Span::empty(),
},
},
expr_from_projection(only(&select.projection)),
);
@ -5877,7 +5883,10 @@ fn parse_literal_datetime() {
assert_eq!(
&Expr::TypedString {
data_type: DataType::Datetime(None),
value: Value::SingleQuotedString("1999-01-01 01:23:34.45".into()),
value: ValueWithSpan {
value: Value::SingleQuotedString("1999-01-01 01:23:34.45".into()),
span: Span::empty(),
},
},
expr_from_projection(only(&select.projection)),
);
@ -5890,7 +5899,10 @@ fn parse_literal_timestamp_without_time_zone() {
assert_eq!(
&Expr::TypedString {
data_type: DataType::Timestamp(None, TimezoneInfo::None),
value: Value::SingleQuotedString("1999-01-01 01:23:34".into()),
value: ValueWithSpan {
value: Value::SingleQuotedString("1999-01-01 01:23:34".into()),
span: Span::empty(),
},
},
expr_from_projection(only(&select.projection)),
);
@ -5905,7 +5917,10 @@ fn parse_literal_timestamp_with_time_zone() {
assert_eq!(
&Expr::TypedString {
data_type: DataType::Timestamp(None, TimezoneInfo::Tz),
value: Value::SingleQuotedString("1999-01-01 01:23:34Z".into()),
value: ValueWithSpan {
value: Value::SingleQuotedString("1999-01-01 01:23:34Z".into()),
span: Span::empty(),
},
},
expr_from_projection(only(&select.projection)),
);
@ -6477,8 +6492,9 @@ fn parse_json_keyword() {
assert_eq!(
&Expr::TypedString {
data_type: DataType::JSON,
value: Value::SingleQuotedString(
r#"{
value: ValueWithSpan {
value: Value::SingleQuotedString(
r#"{
"id": 10,
"type": "fruit",
"name": "apple",
@ -6498,8 +6514,10 @@ fn parse_json_keyword() {
]
}
}"#
.to_string()
)
.to_string()
),
span: Span::empty(),
}
},
expr_from_projection(only(&select.projection)),
);
@ -6511,7 +6529,10 @@ fn parse_typed_strings() {
assert_eq!(
Expr::TypedString {
data_type: DataType::JSON,
value: Value::SingleQuotedString(r#"{"foo":"bar"}"#.into())
value: ValueWithSpan {
value: Value::SingleQuotedString(r#"{"foo":"bar"}"#.into()),
span: Span::empty(),
}
},
expr
);
@ -6529,7 +6550,10 @@ fn parse_bignumeric_keyword() {
assert_eq!(
&Expr::TypedString {
data_type: DataType::BigNumeric(ExactNumberInfo::None),
value: Value::SingleQuotedString(r#"0"#.into())
value: ValueWithSpan {
value: Value::SingleQuotedString(r#"0"#.into()),
span: Span::empty(),
}
},
expr_from_projection(only(&select.projection)),
);
@ -6540,7 +6564,10 @@ fn parse_bignumeric_keyword() {
assert_eq!(
&Expr::TypedString {
data_type: DataType::BigNumeric(ExactNumberInfo::None),
value: Value::SingleQuotedString(r#"123456"#.into())
value: ValueWithSpan {
value: Value::SingleQuotedString(r#"123456"#.into()),
span: Span::empty(),
}
},
expr_from_projection(only(&select.projection)),
);
@ -6551,7 +6578,10 @@ fn parse_bignumeric_keyword() {
assert_eq!(
&Expr::TypedString {
data_type: DataType::BigNumeric(ExactNumberInfo::None),
value: Value::SingleQuotedString(r#"-3.14"#.into())
value: ValueWithSpan {
value: Value::SingleQuotedString(r#"-3.14"#.into()),
span: Span::empty(),
}
},
expr_from_projection(only(&select.projection)),
);
@ -6562,7 +6592,10 @@ fn parse_bignumeric_keyword() {
assert_eq!(
&Expr::TypedString {
data_type: DataType::BigNumeric(ExactNumberInfo::None),
value: Value::SingleQuotedString(r#"-0.54321"#.into())
value: ValueWithSpan {
value: Value::SingleQuotedString(r#"-0.54321"#.into()),
span: Span::empty(),
}
},
expr_from_projection(only(&select.projection)),
);
@ -6573,7 +6606,10 @@ fn parse_bignumeric_keyword() {
assert_eq!(
&Expr::TypedString {
data_type: DataType::BigNumeric(ExactNumberInfo::None),
value: Value::SingleQuotedString(r#"1.23456e05"#.into())
value: ValueWithSpan {
value: Value::SingleQuotedString(r#"1.23456e05"#.into()),
span: Span::empty(),
}
},
expr_from_projection(only(&select.projection)),
);
@ -6584,7 +6620,10 @@ fn parse_bignumeric_keyword() {
assert_eq!(
&Expr::TypedString {
data_type: DataType::BigNumeric(ExactNumberInfo::None),
value: Value::SingleQuotedString(r#"-9.876e-3"#.into())
value: ValueWithSpan {
value: Value::SingleQuotedString(r#"-9.876e-3"#.into()),
span: Span::empty(),
}
},
expr_from_projection(only(&select.projection)),
);
@ -14833,7 +14872,10 @@ fn test_geometry_type() {
all_dialects_where(|d| d.supports_geometric_types()).verified_expr(sql),
Expr::TypedString {
data_type: DataType::GeometricType(GeometricTypeKind::Point),
value: Value::SingleQuotedString("1,2".to_string()),
value: ValueWithSpan {
value: Value::SingleQuotedString("1,2".to_string()),
span: Span::empty(),
},
}
);
@ -14842,7 +14884,10 @@ fn test_geometry_type() {
all_dialects_where(|d| d.supports_geometric_types()).verified_expr(sql),
Expr::TypedString {
data_type: DataType::GeometricType(GeometricTypeKind::Line),
value: Value::SingleQuotedString("1,2,3,4".to_string()),
value: ValueWithSpan {
value: Value::SingleQuotedString("1,2,3,4".to_string()),
span: Span::empty(),
},
}
);
@ -14851,7 +14896,10 @@ fn test_geometry_type() {
all_dialects_where(|d| d.supports_geometric_types()).verified_expr(sql),
Expr::TypedString {
data_type: DataType::GeometricType(GeometricTypeKind::GeometricPath),
value: Value::SingleQuotedString("1,2,3,4".to_string()),
value: ValueWithSpan {
value: Value::SingleQuotedString("1,2,3,4".to_string()),
span: Span::empty(),
},
}
);
let sql = "box '1,2,3,4'";
@ -14859,7 +14907,10 @@ fn test_geometry_type() {
all_dialects_where(|d| d.supports_geometric_types()).verified_expr(sql),
Expr::TypedString {
data_type: DataType::GeometricType(GeometricTypeKind::GeometricBox),
value: Value::SingleQuotedString("1,2,3,4".to_string()),
value: ValueWithSpan {
value: Value::SingleQuotedString("1,2,3,4".to_string()),
span: Span::empty(),
},
}
);
@ -14868,7 +14919,10 @@ fn test_geometry_type() {
all_dialects_where(|d| d.supports_geometric_types()).verified_expr(sql),
Expr::TypedString {
data_type: DataType::GeometricType(GeometricTypeKind::Circle),
value: Value::SingleQuotedString("1,2,3".to_string()),
value: ValueWithSpan {
value: Value::SingleQuotedString("1,2,3".to_string()),
span: Span::empty(),
},
}
);
@ -14877,7 +14931,10 @@ fn test_geometry_type() {
all_dialects_where(|d| d.supports_geometric_types()).verified_expr(sql),
Expr::TypedString {
data_type: DataType::GeometricType(GeometricTypeKind::Polygon),
value: Value::SingleQuotedString("1,2,3,4".to_string()),
value: ValueWithSpan {
value: Value::SingleQuotedString("1,2,3,4".to_string()),
span: Span::empty(),
},
}
);
let sql = "lseg '1,2,3,4'";
@ -14885,7 +14942,10 @@ fn test_geometry_type() {
all_dialects_where(|d| d.supports_geometric_types()).verified_expr(sql),
Expr::TypedString {
data_type: DataType::GeometricType(GeometricTypeKind::LineSegment),
value: Value::SingleQuotedString("1,2,3,4".to_string()),
value: ValueWithSpan {
value: Value::SingleQuotedString("1,2,3,4".to_string()),
span: Span::empty(),
},
}
);
}