Skip to content

Parser fails for updates that include subqueries for source tables #269

Open
@juacala

Description

@juacala

The SQL Parser fails to parse the following query:

update `table1` as e, (select * from table2) e2
set
e.`id` = e2.id,
where e.id=e2.id

It returns the output below. This appears to always be an issue when using subqueries in the table references.

[
    {
        "tables": [
            {
                "database": null,
                "table": "table1",
                "column": null,
                "expr": "`table1`",
                "alias": "e",
                "function": null,
                "subquery": null
            }
        ],
        "set": null,
        "where": null,
        "order": null,
        "limit": null,
        "options": {
            "options": []
        },
        "first": 0,
        "last": 10
    },
    {
        "expr": [
            {
                "database": null,
                "table": null,
                "column": null,
                "expr": "*",
                "alias": null,
                "function": null,
                "subquery": null
            }
        ],
        "from": [
            {
                "database": null,
                "table": "table2",
                "column": null,
                "expr": "table2",
                "alias": null,
                "function": null,
                "subquery": null
            }
        ],
        "index_hints": null,
        "partition": null,
        "where": null,
        "group": null,
        "having": null,
        "order": null,
        "limit": null,
        "procedure": null,
        "into": null,
        "join": null,
        "union": [],
        "end_options": null,
        "options": {
            "options": []
        },
        "first": 11,
        "last": 21
    },
    {
        "options": {
            "options": []
        },
        "end_options": null,
        "set": [
            {
                "column": "e.`id`",
                "value": "e2.id"
            }
        ],
        "first": 22,
        "last": 44,
        "where": [
            {
                "identifiers": [
                    "e",
                    "id",
                    "e2"
                ],
                "isOperator": false,
                "expr": "e.id=e2.id"
            }
        ]
    }
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions