@@ -1929,13 +1929,8 @@ fn parse_select_with_numeric_prefix_column_name() {
1929
1929
#[ test]
1930
1930
fn parse_qualified_identifiers_with_numeric_prefix ( ) {
1931
1931
// Case 1: Qualified column name that starts with digits.
1932
- mysql ( ) . verified_stmt ( "SELECT t.15to29 FROM my_table AS t" ) ;
1933
- match mysql ( )
1934
- . parse_sql_statements ( "SELECT t.15to29 FROM my_table AS t" )
1935
- . unwrap ( )
1936
- . pop ( )
1937
- {
1938
- Some ( Statement :: Query ( q) ) => match * q. body {
1932
+ match mysql ( ) . verified_stmt ( "SELECT t.15to29 FROM my_table AS t" ) {
1933
+ Statement :: Query ( q) => match * q. body {
1939
1934
SetExpr :: Select ( s) => match s. projection . last ( ) {
1940
1935
Some ( SelectItem :: UnnamedExpr ( Expr :: CompoundIdentifier ( parts) ) ) => {
1941
1936
assert_eq ! ( & [ Ident :: new( "t" ) , Ident :: new( "15to29" ) ] , & parts[ ..] ) ;
@@ -1948,13 +1943,8 @@ fn parse_qualified_identifiers_with_numeric_prefix() {
1948
1943
}
1949
1944
1950
1945
// Case 2: Qualified column name that starts with digits and on its own represents a number.
1951
- mysql ( ) . verified_stmt ( "SELECT t.15e29 FROM my_table AS t" ) ;
1952
- match mysql ( )
1953
- . parse_sql_statements ( "SELECT t.15e29 FROM my_table AS t" )
1954
- . unwrap ( )
1955
- . pop ( )
1956
- {
1957
- Some ( Statement :: Query ( q) ) => match * q. body {
1946
+ match mysql ( ) . verified_stmt ( "SELECT t.15e29 FROM my_table AS t" ) {
1947
+ Statement :: Query ( q) => match * q. body {
1958
1948
SetExpr :: Select ( s) => match s. projection . last ( ) {
1959
1949
Some ( SelectItem :: UnnamedExpr ( Expr :: CompoundIdentifier ( parts) ) ) => {
1960
1950
assert_eq ! ( & [ Ident :: new( "t" ) , Ident :: new( "15e29" ) ] , & parts[ ..] ) ;
@@ -1985,13 +1975,8 @@ fn parse_qualified_identifiers_with_numeric_prefix() {
1985
1975
}
1986
1976
1987
1977
// Case 4: Quoted simple identifier.
1988
- mysql ( ) . verified_stmt ( "SELECT `15e29` FROM my_table" ) ;
1989
- match mysql ( )
1990
- . parse_sql_statements ( "SELECT `15e29` FROM my_table" )
1991
- . unwrap ( )
1992
- . pop ( )
1993
- {
1994
- Some ( Statement :: Query ( q) ) => match * q. body {
1978
+ match mysql ( ) . verified_stmt ( "SELECT `15e29` FROM my_table" ) {
1979
+ Statement :: Query ( q) => match * q. body {
1995
1980
SetExpr :: Select ( s) => match s. projection . last ( ) {
1996
1981
Some ( SelectItem :: UnnamedExpr ( Expr :: Identifier ( name) ) ) => {
1997
1982
assert_eq ! ( & Ident :: with_quote( '`' , "15e29" ) , name) ;
@@ -2004,13 +1989,8 @@ fn parse_qualified_identifiers_with_numeric_prefix() {
2004
1989
}
2005
1990
2006
1991
// Case 5: Quoted compound identifier.
2007
- mysql ( ) . verified_stmt ( "SELECT t.`15e29` FROM my_table" ) ;
2008
- match mysql ( )
2009
- . parse_sql_statements ( "SELECT t.`15e29` FROM my_table AS t" )
2010
- . unwrap ( )
2011
- . pop ( )
2012
- {
2013
- Some ( Statement :: Query ( q) ) => match * q. body {
1992
+ match mysql ( ) . verified_stmt ( "SELECT t.`15e29` FROM my_table AS t" ) {
1993
+ Statement :: Query ( q) => match * q. body {
2014
1994
SetExpr :: Select ( s) => match s. projection . last ( ) {
2015
1995
Some ( SelectItem :: UnnamedExpr ( Expr :: CompoundIdentifier ( parts) ) ) => {
2016
1996
assert_eq ! (
@@ -2024,6 +2004,48 @@ fn parse_qualified_identifiers_with_numeric_prefix() {
2024
2004
} ,
2025
2005
stmt => panic ! ( "Unexpected statement: {:?}" , stmt) ,
2026
2006
}
2007
+
2008
+ // Case 6: Multi-level compound identifiers.
2009
+ match mysql ( ) . verified_stmt ( "SELECT 1db.1table.1column" ) {
2010
+ Statement :: Query ( q) => match * q. body {
2011
+ SetExpr :: Select ( s) => match s. projection . last ( ) {
2012
+ Some ( SelectItem :: UnnamedExpr ( Expr :: CompoundIdentifier ( parts) ) ) => {
2013
+ assert_eq ! (
2014
+ & [
2015
+ Ident :: new( "1db" ) ,
2016
+ Ident :: new( "1table" ) ,
2017
+ Ident :: new( "1column" )
2018
+ ] ,
2019
+ & parts[ ..]
2020
+ ) ;
2021
+ }
2022
+ proj => panic ! ( "Unexpected projection: {:?}" , proj) ,
2023
+ } ,
2024
+ body => panic ! ( "Unexpected statement body: {:?}" , body) ,
2025
+ } ,
2026
+ stmt => panic ! ( "Unexpected statement: {:?}" , stmt) ,
2027
+ }
2028
+
2029
+ // Case 7: Multi-level compound quoted identifiers.
2030
+ match mysql ( ) . verified_stmt ( "SELECT `1`.`2`.`3`" ) {
2031
+ Statement :: Query ( q) => match * q. body {
2032
+ SetExpr :: Select ( s) => match s. projection . last ( ) {
2033
+ Some ( SelectItem :: UnnamedExpr ( Expr :: CompoundIdentifier ( parts) ) ) => {
2034
+ assert_eq ! (
2035
+ & [
2036
+ Ident :: with_quote( '`' , "1" ) ,
2037
+ Ident :: with_quote( '`' , "2" ) ,
2038
+ Ident :: with_quote( '`' , "3" )
2039
+ ] ,
2040
+ & parts[ ..]
2041
+ ) ;
2042
+ }
2043
+ proj => panic ! ( "Unexpected projection: {:?}" , proj) ,
2044
+ } ,
2045
+ body => panic ! ( "Unexpected statement body: {:?}" , body) ,
2046
+ } ,
2047
+ stmt => panic ! ( "Unexpected statement: {:?}" , stmt) ,
2048
+ }
2027
2049
}
2028
2050
2029
2051
// Don't run with bigdecimal as it fails like this on rust beta:
0 commit comments