Skip to content

Commit 1ddc47b

Browse files
author
Roman Borschel
committed
Address linter errors.
1 parent 076e47c commit 1ddc47b

File tree

2 files changed

+56
-34
lines changed

2 files changed

+56
-34
lines changed

src/tokenizer.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,11 @@ impl<'a> Tokenizer<'a> {
932932
}
933933

934934
/// Get the next token or return None
935-
fn next_token(&self, chars: &mut State, prev_token: Option<&Token>) -> Result<Option<Token>, TokenizerError> {
935+
fn next_token(
936+
&self,
937+
chars: &mut State,
938+
prev_token: Option<&Token>,
939+
) -> Result<Option<Token>, TokenizerError> {
936940
match chars.peek() {
937941
Some(&ch) => match ch {
938942
' ' => self.consume_and_return(chars, Token::Whitespace(Whitespace::Space)),
@@ -3984,19 +3988,11 @@ mod tests {
39843988

39853989
#[test]
39863990
fn test_tokenize_identifiers_numeric_prefix() {
3987-
all_dialects_where(|dialect| dialect.supports_numeric_prefix()).tokenizes_to(
3988-
"123abc",
3989-
vec![
3990-
Token::make_word("123abc", None),
3991-
],
3992-
);
3991+
all_dialects_where(|dialect| dialect.supports_numeric_prefix())
3992+
.tokenizes_to("123abc", vec![Token::make_word("123abc", None)]);
39933993

3994-
all_dialects_where(|dialect| dialect.supports_numeric_prefix()).tokenizes_to(
3995-
"12e34",
3996-
vec![
3997-
Token::Number("12e34".to_string(), false),
3998-
],
3999-
);
3994+
all_dialects_where(|dialect| dialect.supports_numeric_prefix())
3995+
.tokenizes_to("12e34", vec![Token::Number("12e34".to_string(), false)]);
40003996

40013997
all_dialects_where(|dialect| dialect.supports_numeric_prefix()).tokenizes_to(
40023998
"t.12e34",

tests/sqlparser_mysql.rs

Lines changed: 47 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,76 +1930,102 @@ fn parse_select_with_numeric_prefix_column_name() {
19301930
fn parse_qualified_identifiers_with_numeric_prefix() {
19311931
// Case 1: Qualified column name that starts with digits.
19321932
mysql().verified_stmt("SELECT t.15to29 FROM my_table AS t");
1933-
match mysql().parse_sql_statements("SELECT t.15to29 FROM my_table AS t").unwrap().pop() {
1933+
match mysql()
1934+
.parse_sql_statements("SELECT t.15to29 FROM my_table AS t")
1935+
.unwrap()
1936+
.pop()
1937+
{
19341938
Some(Statement::Query(q)) => match *q.body {
19351939
SetExpr::Select(s) => match s.projection.last() {
1936-
Some(SelectItem::UnnamedExpr(Expr::CompoundIdentifier(parts))) => {
1940+
Some(SelectItem::UnnamedExpr(Expr::CompoundIdentifier(parts))) => {
19371941
assert_eq!(&[Ident::new("t"), Ident::new("15to29")], &parts[..]);
19381942
}
19391943
proj => panic!("Unexpected projection: {:?}", proj),
1940-
}
1944+
},
19411945
body => panic!("Unexpected statement body: {:?}", body),
1942-
}
1946+
},
19431947
stmt => panic!("Unexpected statement: {:?}", stmt),
19441948
}
19451949

19461950
// Case 2: Qualified column name that starts with digits and on its own represents a number.
19471951
mysql().verified_stmt("SELECT t.15e29 FROM my_table AS t");
1948-
match mysql().parse_sql_statements("SELECT t.15e29 FROM my_table AS t").unwrap().pop() {
1952+
match mysql()
1953+
.parse_sql_statements("SELECT t.15e29 FROM my_table AS t")
1954+
.unwrap()
1955+
.pop()
1956+
{
19491957
Some(Statement::Query(q)) => match *q.body {
19501958
SetExpr::Select(s) => match s.projection.last() {
1951-
Some(SelectItem::UnnamedExpr(Expr::CompoundIdentifier(parts))) => {
1959+
Some(SelectItem::UnnamedExpr(Expr::CompoundIdentifier(parts))) => {
19521960
assert_eq!(&[Ident::new("t"), Ident::new("15e29")], &parts[..]);
19531961
}
19541962
proj => panic!("Unexpected projection: {:?}", proj),
1955-
}
1963+
},
19561964
body => panic!("Unexpected statement body: {:?}", body),
1957-
}
1965+
},
19581966
stmt => panic!("Unexpected statement: {:?}", stmt),
19591967
}
19601968

19611969
// Case 3: Unqualified, the same token is parsed as a number.
19621970
mysql().verified_stmt("SELECT 15e29 FROM my_table");
1963-
match mysql().parse_sql_statements("SELECT 15e29 FROM my_table").unwrap().pop() {
1971+
match mysql()
1972+
.parse_sql_statements("SELECT 15e29 FROM my_table")
1973+
.unwrap()
1974+
.pop()
1975+
{
19641976
Some(Statement::Query(q)) => match *q.body {
19651977
SetExpr::Select(s) => match s.projection.last() {
1966-
Some(SelectItem::UnnamedExpr(Expr::Value(ValueWithSpan { value: Value::Number(n, _), ..}))) => {
1978+
Some(SelectItem::UnnamedExpr(Expr::Value(ValueWithSpan {
1979+
value: Value::Number(n, _),
1980+
..
1981+
}))) => {
19671982
assert_eq!("15e29", n);
19681983
}
19691984
proj => panic!("Unexpected projection: {:?}", proj),
1970-
}
1985+
},
19711986
body => panic!("Unexpected statement body: {:?}", body),
1972-
}
1987+
},
19731988
stmt => panic!("Unexpected statement: {:?}", stmt),
19741989
}
19751990

19761991
// Case 4: Quoted simple identifier.
19771992
mysql().verified_stmt("SELECT `15e29` FROM my_table");
1978-
match mysql().parse_sql_statements("SELECT `15e29` FROM my_table").unwrap().pop() {
1993+
match mysql()
1994+
.parse_sql_statements("SELECT `15e29` FROM my_table")
1995+
.unwrap()
1996+
.pop()
1997+
{
19791998
Some(Statement::Query(q)) => match *q.body {
19801999
SetExpr::Select(s) => match s.projection.last() {
1981-
Some(SelectItem::UnnamedExpr(Expr::Identifier(name))) => {
2000+
Some(SelectItem::UnnamedExpr(Expr::Identifier(name))) => {
19822001
assert_eq!(&Ident::with_quote('`', "15e29"), name);
19832002
}
19842003
proj => panic!("Unexpected projection: {:?}", proj),
1985-
}
2004+
},
19862005
body => panic!("Unexpected statement body: {:?}", body),
1987-
}
2006+
},
19882007
stmt => panic!("Unexpected statement: {:?}", stmt),
19892008
}
19902009

19912010
// Case 5: Quoted compound identifier.
19922011
mysql().verified_stmt("SELECT t.`15e29` FROM my_table");
1993-
match mysql().parse_sql_statements("SELECT t.`15e29` FROM my_table AS t").unwrap().pop() {
2012+
match mysql()
2013+
.parse_sql_statements("SELECT t.`15e29` FROM my_table AS t")
2014+
.unwrap()
2015+
.pop()
2016+
{
19942017
Some(Statement::Query(q)) => match *q.body {
19952018
SetExpr::Select(s) => match s.projection.last() {
1996-
Some(SelectItem::UnnamedExpr(Expr::CompoundIdentifier(parts))) => {
1997-
assert_eq!(&[Ident::new("t"), Ident::with_quote('`', "15e29")], &parts[..]);
2019+
Some(SelectItem::UnnamedExpr(Expr::CompoundIdentifier(parts))) => {
2020+
assert_eq!(
2021+
&[Ident::new("t"), Ident::with_quote('`', "15e29")],
2022+
&parts[..]
2023+
);
19982024
}
19992025
proj => panic!("Unexpected projection: {:?}", proj),
2000-
}
2026+
},
20012027
body => panic!("Unexpected statement body: {:?}", body),
2002-
}
2028+
},
20032029
stmt => panic!("Unexpected statement: {:?}", stmt),
20042030
}
20052031
}

0 commit comments

Comments
 (0)