Skip to content

Commit 1339522

Browse files
committed
refactor: fix location different for same sql in different dialect
1 parent 1936591 commit 1339522

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

pegjs/mysql.pegjs

+16-2
Original file line numberDiff line numberDiff line change
@@ -2274,12 +2274,13 @@ column_list_item
22742274
...getLocationObject(),
22752275
};
22762276
}
2277-
/ table:(ident __ DOT)? __ STAR {
2277+
/ tbl:(ident __ DOT)? __ STAR {
2278+
const table = tbl && tbl[0] || null
22782279
columnList.add(`select::${table}::(.*)`);
22792280
return {
22802281
expr: {
22812282
type: 'column_ref',
2282-
table: table && table[0] || null,
2283+
table,
22832284
column: '*'
22842285
},
22852286
as: null,
@@ -3119,6 +3120,19 @@ column_ref
31193120
...getLocationObject(),
31203121
};
31213122
}
3123+
/ tbl:(ident __ DOT)? __ STAR {
3124+
const table = tbl && tbl[0] || null
3125+
columnList.add(`select::${table}::(.*)`);
3126+
return {
3127+
expr: {
3128+
type: 'column_ref',
3129+
table,
3130+
column: '*'
3131+
},
3132+
as: null,
3133+
...getLocationObject(),
3134+
};
3135+
}
31223136
/ col:column {
31233137
columnList.add(`select::null::${col}`);
31243138
return {

pegjs/trino.pegjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4027,7 +4027,7 @@ cast_expr
40274027
...c,
40284028
}
40294029
}
4030-
/ e:(func_call/ aggr_func / window_func / case_expr / interval_expr / literal / column_ref_array_index / param) __ c:cast_double_colon? {
4030+
/ e:(func_call/ aggr_func / window_func / case_expr / interval_expr / literal / column_ref_array_index / param) __ c:cast_double_colon? {
40314031
/* => {
40324032
type: 'cast';
40334033
expr: literal | aggr_func | func_call | case_expr | interval_expr | column_ref | param

0 commit comments

Comments
 (0)