mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-09-27 16:09:09 +00:00
MySQL dialect: Add support for hash comments (#1466)
This commit is contained in:
parent
a4fa9e08b7
commit
749b061fbf
2 changed files with 8 additions and 3 deletions
|
@ -43,7 +43,8 @@ use sqlparser_derive::{Visit, VisitMut};
|
||||||
use crate::ast::DollarQuotedString;
|
use crate::ast::DollarQuotedString;
|
||||||
use crate::dialect::Dialect;
|
use crate::dialect::Dialect;
|
||||||
use crate::dialect::{
|
use crate::dialect::{
|
||||||
BigQueryDialect, DuckDbDialect, GenericDialect, PostgreSqlDialect, SnowflakeDialect,
|
BigQueryDialect, DuckDbDialect, GenericDialect, MySqlDialect, PostgreSqlDialect,
|
||||||
|
SnowflakeDialect,
|
||||||
};
|
};
|
||||||
use crate::keywords::{Keyword, ALL_KEYWORDS, ALL_KEYWORDS_INDEX};
|
use crate::keywords::{Keyword, ALL_KEYWORDS, ALL_KEYWORDS_INDEX};
|
||||||
|
|
||||||
|
@ -1140,7 +1141,7 @@ impl<'a> Tokenizer<'a> {
|
||||||
}
|
}
|
||||||
'{' => self.consume_and_return(chars, Token::LBrace),
|
'{' => self.consume_and_return(chars, Token::LBrace),
|
||||||
'}' => self.consume_and_return(chars, Token::RBrace),
|
'}' => self.consume_and_return(chars, Token::RBrace),
|
||||||
'#' if dialect_of!(self is SnowflakeDialect | BigQueryDialect) => {
|
'#' if dialect_of!(self is SnowflakeDialect | BigQueryDialect | MySqlDialect) => {
|
||||||
chars.next(); // consume the '#', starting a snowflake single-line comment
|
chars.next(); // consume the '#', starting a snowflake single-line comment
|
||||||
let comment = self.tokenize_single_line_comment(chars);
|
let comment = self.tokenize_single_line_comment(chars);
|
||||||
Ok(Some(Token::Whitespace(Whitespace::SingleLineComment {
|
Ok(Some(Token::Whitespace(Whitespace::SingleLineComment {
|
||||||
|
|
|
@ -9923,7 +9923,11 @@ fn test_release_savepoint() {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_comment_hash_syntax() {
|
fn test_comment_hash_syntax() {
|
||||||
let dialects = TestedDialects {
|
let dialects = TestedDialects {
|
||||||
dialects: vec![Box::new(BigQueryDialect {}), Box::new(SnowflakeDialect {})],
|
dialects: vec![
|
||||||
|
Box::new(BigQueryDialect {}),
|
||||||
|
Box::new(SnowflakeDialect {}),
|
||||||
|
Box::new(MySqlDialect {}),
|
||||||
|
],
|
||||||
options: None,
|
options: None,
|
||||||
};
|
};
|
||||||
let sql = r#"
|
let sql = r#"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue