File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed
Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -189,6 +189,11 @@ fn parse_from_list(p: &mut Parser) {
189189 if !expect_join {
190190 parse_ident( p, 1 ..1 ) ;
191191 }
192+ if let Some ( x) = p. nth( 1 ) {
193+ if JOIN_TOKENS . contains( & x) && !JOIN_TOKENS . contains( & p. current( ) ) {
194+ parse_ident( p, 1 ..1 ) ;
195+ }
196+ }
192197 if JOIN_TOKENS . contains( & p. current( ) ) {
193198 let expect_r_param = p. eat( T ![ "(" ] ) ;
194199 parse_join_clause( p) ;
@@ -241,6 +246,9 @@ fn parse_inner_join_clause(p: &mut Parser) {
241246 p. eat ( T ! [ inner] ) ;
242247 p. expect ( T ! [ join] ) ;
243248 parse_ident ( p, 1 ..2 ) ;
249+ if !p. at ( T ! [ on] ) || p. at ( T ! [ using] ) {
250+ parse_ident ( p, 1 ..1 ) ;
251+ }
244252 match p. current ( ) {
245253 T ! [ on] => {
246254 p. expect ( T ! [ on] ) ;
@@ -1901,6 +1909,54 @@ Root@0..56
19011909 Dot@52..53 "."
19021910 Ident@53..55 "id"
19031911 Semicolon@55..56 ";"
1912+ "# ] ] ,
1913+ vec ! [ ] ,
1914+ ) ;
1915+ }
1916+
1917+ #[ test]
1918+ fn test_join_alias ( ) {
1919+ check (
1920+ parse ( "SELECT * FROM abc a JOIN def d ON a.id=d.id" , |p| {
1921+ parse_query ( p, false )
1922+ } ) ,
1923+ expect ! [ [ r#"
1924+ Root@0..43
1925+ SelectStmt@0..43
1926+ Keyword@0..6 "SELECT"
1927+ Whitespace@6..7 " "
1928+ Asterisk@7..8 "*"
1929+ Whitespace@8..9 " "
1930+ Keyword@9..13 "FROM"
1931+ Whitespace@13..14 " "
1932+ IdentGroup@14..17
1933+ Ident@14..17 "abc"
1934+ Whitespace@17..18 " "
1935+ IdentGroup@18..19
1936+ Ident@18..19 "a"
1937+ Whitespace@19..20 " "
1938+ JoinClause@20..43
1939+ InnerJoinClause@20..43
1940+ Keyword@20..24 "JOIN"
1941+ Whitespace@24..25 " "
1942+ IdentGroup@25..28
1943+ Ident@25..28 "def"
1944+ Whitespace@28..29 " "
1945+ IdentGroup@29..30
1946+ Ident@29..30 "d"
1947+ Whitespace@30..31 " "
1948+ Keyword@31..33 "ON"
1949+ Whitespace@33..34 " "
1950+ Expression@34..43
1951+ IdentGroup@34..38
1952+ Ident@34..35 "a"
1953+ Dot@35..36 "."
1954+ Ident@36..38 "id"
1955+ ComparisonOp@38..39 "="
1956+ IdentGroup@39..43
1957+ Ident@39..40 "d"
1958+ Dot@40..41 "."
1959+ Ident@41..43 "id"
19041960"# ] ] ,
19051961 vec ! [ ] ,
19061962 ) ;
You can’t perform that action at this time.
0 commit comments