subquery
can not parse some sqls. would you like help me to solve this problem example "SELECT *, (SELECT group_concat(inner_url) inner_url FROM t_media_info b WHERE a.id = b.msg_id GROUP BY msg_id) inner_url WHERE f_step = 1 AND business_id IN (6, 3, 4, 8, 9, 12, 14, 15, 38, 39, 5) ORDER BY create_time DESC
To fix the issue we would have to make a breaking change, because the parser cannot handle "*" and columns/subselects in one query at the moment.
To workaround the problem you need to replace the "*" by single columns. Maybe a different parser (e.g. node-sql-parser) might handle your query.
Thank for your reply, I fixed this subquery。(I have taken over a project that involves this package. Recently, i need to add some feature to it)
/subquery_clause
= '(' __ stmt:select_stmt __ ')' {
stmt.parentheses = true
return stmt
}
// (SELECT * FROM `t_mi_partner_interface_privilege`) AS `total`
// t_aa.*
// (SELECT * FROM `t_mi_partner_interface_privilege`) `total`
// f_test aaa
column_list_item
=
(KW_ALL / (STAR !ident_start))?{
return {
expr: {
type: 'column_ref',
column: '*'
},
as: null
}
}
/ tbl:ident __ DOT __ STAR {
return {
expr: {
type: 'column_ref',
table: tbl,
column: '*'
},
as: null
};
}
/ subquery:subquery_clause __ alias:alias_clause? {
return { expr: subquery, as: alias || null, column:alias };
}
/ e:expr __ alias:alias_clause? {
return { expr: e, as: alias };
}
```shell