mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-31 11:17:23 +00:00
feat: mysql no-escape mode (#870)
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
This commit is contained in:
parent
eb288487a6
commit
f98a2f9dca
7 changed files with 485 additions and 121 deletions
|
@ -1004,11 +1004,13 @@ fn parse_select_with_date_column_name() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn parse_escaped_single_quote_string_predicate() {
|
||||
fn parse_escaped_single_quote_string_predicate_with_escape() {
|
||||
use self::BinaryOperator::*;
|
||||
let sql = "SELECT id, fname, lname FROM customer \
|
||||
WHERE salary <> 'Jim''s salary'";
|
||||
|
||||
let ast = verified_only_select(sql);
|
||||
|
||||
assert_eq!(
|
||||
Some(Expr::BinaryOp {
|
||||
left: Box::new(Expr::Identifier(Ident::new("salary"))),
|
||||
|
@ -1021,6 +1023,34 @@ fn parse_escaped_single_quote_string_predicate() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_escaped_single_quote_string_predicate_with_no_escape() {
|
||||
use self::BinaryOperator::*;
|
||||
let sql = "SELECT id, fname, lname FROM customer \
|
||||
WHERE salary <> 'Jim''s salary'";
|
||||
|
||||
let ast = TestedDialects {
|
||||
dialects: vec![Box::new(MySqlDialect {})],
|
||||
options: Some(
|
||||
ParserOptions::new()
|
||||
.with_trailing_commas(true)
|
||||
.with_unescape(false),
|
||||
),
|
||||
}
|
||||
.verified_only_select(sql);
|
||||
|
||||
assert_eq!(
|
||||
Some(Expr::BinaryOp {
|
||||
left: Box::new(Expr::Identifier(Ident::new("salary"))),
|
||||
op: NotEq,
|
||||
right: Box::new(Expr::Value(Value::SingleQuotedString(
|
||||
"Jim''s salary".to_string()
|
||||
))),
|
||||
}),
|
||||
ast.selection,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_number() {
|
||||
let expr = verified_expr("1.0");
|
||||
|
@ -7264,9 +7294,7 @@ fn parse_non_latin_identifiers() {
|
|||
fn parse_trailing_comma() {
|
||||
let trailing_commas = TestedDialects {
|
||||
dialects: vec![Box::new(GenericDialect {})],
|
||||
options: Some(ParserOptions {
|
||||
trailing_commas: true,
|
||||
}),
|
||||
options: Some(ParserOptions::new().with_trailing_commas(true)),
|
||||
};
|
||||
|
||||
trailing_commas.one_statement_parses_to(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue