Skip to content

Commit 1ead5c9

Browse files
committed
move common test
1 parent e79d799 commit 1ead5c9

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

tests/sqlparser_bigquery.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2240,7 +2240,9 @@ fn test_select_as_value() {
22402240
}
22412241

22422242
#[test]
2243-
fn test_typed_strings() {
2243+
fn test_triple_quote_typed_strings() {
2244+
bigquery().verified_expr(r#"JSON '''{"foo":"bar's"}'''"#);
2245+
22442246
let expr = bigquery().verified_expr(r#"JSON """{"foo":"bar's"}""""#);
22452247
assert_eq!(
22462248
Expr::TypedString {
@@ -2249,12 +2251,6 @@ fn test_typed_strings() {
22492251
},
22502252
expr
22512253
);
2252-
2253-
let expr = bigquery().verified_expr(r#"JSON '''{"foo":"bar's"}'''"#);
2254-
if let Expr::TypedString { data_type, value } = expr {
2255-
assert_eq!(DataType::JSON, data_type);
2256-
assert_eq!(r#"{"foo":"bar's"}"#, value.into_string().unwrap());
2257-
}
22582254
}
22592255

22602256
#[test]

tests/sqlparser_common.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6020,6 +6020,23 @@ fn parse_json_keyword() {
60206020
);
60216021
}
60226022

6023+
#[test]
6024+
fn parse_typed_strings() {
6025+
let expr = verified_expr(r#"JSON '{"foo":"bar"}'"#);
6026+
assert_eq!(
6027+
Expr::TypedString {
6028+
data_type: DataType::JSON,
6029+
value: Value::SingleQuotedString(r#"{"foo":"bar"}"#.into())
6030+
},
6031+
expr
6032+
);
6033+
6034+
if let Expr::TypedString { data_type, value } = expr {
6035+
assert_eq!(DataType::JSON, data_type);
6036+
assert_eq!(r#"{"foo":"bar"}"#, value.into_string().unwrap());
6037+
}
6038+
}
6039+
60236040
#[test]
60246041
fn parse_bignumeric_keyword() {
60256042
let sql = r#"SELECT BIGNUMERIC '0'"#;

0 commit comments

Comments
 (0)