phpmyadmin / phpmyadmin/sql-parser
Subquery in expressions support
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 485
- Forks
- 119
- PR merge metrics
- No merged PRs in 30d
Description
It seems to subqueries are poorly supported
Some examples first:
They are not parsed at all
SELECT * FROM (SELECT * FROM b) a
results in
...
PhpMyAdmin\SqlParser\Components\Expression Object
(
[database] =>
[table] =>
[column] =>
[expr] => (SELECT * FROM b)
[alias] => a
[function] =>
[subquery] => SELECT
)
...
not even extracted properly (see #254)
SELECT * FROM a WHERE a.field IN (SELECT * FROM b)
results in
...
...
PhpMyAdmin\SqlParser\Components\Condition Object
(
[identifiers] => Array
(
[0] => a
[1] => field
[2] => b
)
[isOperator] =>
[expr] => a.field IN (SELECT * FROM b)
)
...
So I have an idea. May be there must be separate ExpressionParser generating AST for expression? Those (including me) who needed parsed expression can use it (and extract subselects, and parse it with regular parser), and there will be no compatibility break.
Does it sounds as a good plan? If it does, I would like to implement it.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by examining the existing expression-parsing path and the regular parser described in the examples. Determine how a separate ExpressionParser could represent and extract subqueries while preserving compatibility, then verify the SELECT and WHERE IN examples produce usable parsed subqueries.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, sql
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100