mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-12-23 11:12:51 +00:00
PostgreSQL Tokenization: Fix unexpected characters after question mark being silently ignored (#2129)
Some checks are pending
license / Release Audit Tool (RAT) (push) Waiting to run
Rust / codestyle (push) Waiting to run
Rust / lint (push) Waiting to run
Rust / benchmark-lint (push) Waiting to run
Rust / compile (push) Waiting to run
Rust / docs (push) Waiting to run
Rust / compile-no-std (push) Waiting to run
Rust / test (beta) (push) Waiting to run
Rust / test (nightly) (push) Waiting to run
Rust / test (stable) (push) Waiting to run
Some checks are pending
license / Release Audit Tool (RAT) (push) Waiting to run
Rust / codestyle (push) Waiting to run
Rust / lint (push) Waiting to run
Rust / benchmark-lint (push) Waiting to run
Rust / compile (push) Waiting to run
Rust / docs (push) Waiting to run
Rust / compile-no-std (push) Waiting to run
Rust / test (beta) (push) Waiting to run
Rust / test (nightly) (push) Waiting to run
Rust / test (stable) (push) Waiting to run
This commit is contained in:
parent
d78dbc97a1
commit
39418cfebb
1 changed files with 20 additions and 1 deletions
|
|
@ -1717,7 +1717,7 @@ impl<'a> Tokenizer<'a> {
|
|||
}
|
||||
}
|
||||
Some('#') => self.consume_and_return(chars, Token::QuestionMarkSharp),
|
||||
_ => self.consume_and_return(chars, Token::Question),
|
||||
_ => Ok(Some(Token::Question)),
|
||||
}
|
||||
}
|
||||
'?' => {
|
||||
|
|
@ -4147,4 +4147,23 @@ mod tests {
|
|||
panic!("Tokenizer should have failed on {sql}, but it succeeded with {tokens:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tokenize_question_mark() {
|
||||
let dialect = PostgreSqlDialect {};
|
||||
let sql = "SELECT x ? y";
|
||||
let tokens = Tokenizer::new(&dialect, sql).tokenize().unwrap();
|
||||
compare(
|
||||
tokens,
|
||||
vec![
|
||||
Token::make_keyword("SELECT"),
|
||||
Token::Whitespace(Whitespace::Space),
|
||||
Token::make_word("x", None),
|
||||
Token::Whitespace(Whitespace::Space),
|
||||
Token::Question,
|
||||
Token::Whitespace(Whitespace::Space),
|
||||
Token::make_word("y", None),
|
||||
],
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue