@@ -2040,7 +2040,7 @@ fn parse_ilike() {
20402040 pattern: Box::new(Expr::Value(
20412041 (Value::SingleQuotedString("%a".to_string())).with_empty_span()
20422042 )),
2043- escape_char: Some('^'.to_string()),
2043+ escape_char: Some(Value::SingleQuotedString( '^'.to_string() )),
20442044 any: false,
20452045 },
20462046 select.selection.unwrap()
@@ -2104,7 +2104,7 @@ fn parse_like() {
21042104 pattern: Box::new(Expr::Value(
21052105 (Value::SingleQuotedString("%a".to_string())).with_empty_span()
21062106 )),
2107- escape_char: Some('^'.to_string()),
2107+ escape_char: Some(Value::SingleQuotedString( '^'.to_string() )),
21082108 any: false,
21092109 },
21102110 select.selection.unwrap()
@@ -2167,7 +2167,24 @@ fn parse_similar_to() {
21672167 pattern: Box::new(Expr::Value(
21682168 (Value::SingleQuotedString("%a".to_string())).with_empty_span()
21692169 )),
2170- escape_char: Some('^'.to_string()),
2170+ escape_char: Some(Value::SingleQuotedString('^'.to_string())),
2171+ },
2172+ select.selection.unwrap()
2173+ );
2174+
2175+ let sql = &format!(
2176+ "SELECT * FROM customers WHERE name {}SIMILAR TO '%a' ESCAPE NULL",
2177+ if negated { "NOT " } else { "" }
2178+ );
2179+ let select = verified_only_select(sql);
2180+ assert_eq!(
2181+ Expr::SimilarTo {
2182+ expr: Box::new(Expr::Identifier(Ident::new("name"))),
2183+ negated,
2184+ pattern: Box::new(Expr::Value(
2185+ (Value::SingleQuotedString("%a".to_string())).with_empty_span()
2186+ )),
2187+ escape_char: Some(Value::Null),
21712188 },
21722189 select.selection.unwrap()
21732190 );
@@ -2185,7 +2202,7 @@ fn parse_similar_to() {
21852202 pattern: Box::new(Expr::Value(
21862203 (Value::SingleQuotedString("%a".to_string())).with_empty_span()
21872204 )),
2188- escape_char: Some('^'.to_string()),
2205+ escape_char: Some(Value::SingleQuotedString( '^'.to_string() )),
21892206 })),
21902207 select.selection.unwrap()
21912208 );
0 commit comments