Skip to content

Commit

Permalink
refactor: fix location different for same sql in different dialect
Browse files Browse the repository at this point in the history
  • Loading branch information
taozhi8833998 committed Aug 27, 2024
1 parent 1936591 commit 1339522
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
18 changes: 16 additions & 2 deletions pegjs/mysql.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -2274,12 +2274,13 @@ column_list_item
...getLocationObject(),
};
}
/ table:(ident __ DOT)? __ STAR {
/ tbl:(ident __ DOT)? __ STAR {
const table = tbl && tbl[0] || null
columnList.add(`select::${table}::(.*)`);
return {
expr: {
type: 'column_ref',
table: table && table[0] || null,
table,
column: '*'
},
as: null,
Expand Down Expand Up @@ -3119,6 +3120,19 @@ column_ref
...getLocationObject(),
};
}
/ tbl:(ident __ DOT)? __ STAR {
const table = tbl && tbl[0] || null
columnList.add(`select::${table}::(.*)`);
return {
expr: {
type: 'column_ref',
table,
column: '*'
},
as: null,
...getLocationObject(),
};
}
/ col:column {
columnList.add(`select::null::${col}`);
return {
Expand Down
2 changes: 1 addition & 1 deletion pegjs/trino.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -4027,7 +4027,7 @@ cast_expr
...c,
}
}
/ e:(func_call/ aggr_func / window_func / case_expr / interval_expr / literal / column_ref_array_index / param) __ c:cast_double_colon? {
/ e:(func_call/ aggr_func / window_func / case_expr / interval_expr / literal / column_ref_array_index / param) __ c:cast_double_colon? {
/* => {
type: 'cast';
expr: literal | aggr_func | func_call | case_expr | interval_expr | column_ref | param
Expand Down

0 comments on commit 1339522

Please sign in to comment.