MartinSahlen commented on code in PR #1679:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/1679#discussion_r1933869079
##########
tests/sqlparser_bigquery.rs:
##########
@@ -2214,6 +2214,30 @@ fn test_select_as_value() {
assert_eq!(Some(ValueTableMode::AsValue), select.value_table_mode);
}
+#[test]
+fn test_typed_strings() {
+ let expr = bigquery().verified_expr(r#"JSON """{"foo":"bar's"}""""#);
+ assert_eq!(
+ Expr::TypedString {
+ data_type: DataType::JSON,
+ value: Value::TripleDoubleQuotedString(r#"{"foo":"bar's"}"#.into())
+ },
+ expr
+ );
+
+ let expr = bigquery().verified_expr(r#"JSON '''{"foo":"bar's"}'''"#);
+ if let Expr::TypedString { data_type, value } = expr {
+ assert_eq!(DataType::JSON, data_type);
+ let string_value: String = value.into();
+ assert_eq!(r#"{"foo":"bar's"}"#, string_value);
+ }
+
+ // SingleQuotedString and DoubleQuotedString are currently not correctly
formatted by `fmt::Display for Value`.
+ // BigQuery does not support double escaping, should be \' or \" instead.
+ //bigquery().verified_expr(r#"JSON '{"foo":"bar\'s"}'"#);
+ //bigquery().verified_expr(r#"JSON "{\"foo\":\"bar's\"}""#);
Review Comment:
I think we shouldnt need to set up unescape or other special modes to handle
this case. The parser ingests valid input SQL and outputs buggy SQL in the case
that @graup brings up so it's a pretty clear cut case of a bug?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]