Skip to content

Subquery in expressions support #298

Open
@m0003r

Description

@m0003r

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions