Skip to content

Support for parameterized select clauses #412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bch36 opened this issue Jan 18, 2023 · 2 comments
Closed

Support for parameterized select clauses #412

bch36 opened this issue Jan 18, 2023 · 2 comments
Assignees
Labels
enhancement kind/support A request for adding support
Milestone

Comments

@bch36
Copy link

bch36 commented Jan 18, 2023

When using placeholders in a select clause for a prepared statement, the parser stops at the first placeholder. For example, parsing "SELECT 1, 2, ?, 3" will include the expressions 1 and 2 in the SelectStatement object, but not the placeholder or 3.

PhpMyAdmin\SqlParser\Statements\SelectStatement Object
(
    [expr] => Array
        (
            [0] => PhpMyAdmin\SqlParser\Components\Expression Object
                (
                    [database] => 
                    [table] => 
                    [column] => 
                    [expr] => 1
                    [alias] => 
                    [function] => 
                    [subquery] => 
                )

            [1] => PhpMyAdmin\SqlParser\Components\Expression Object
                (
                    [database] => 
                    [table] => 
                    [column] => 
                    [expr] => 2
                    [alias] => 
                    [function] => 
                    [subquery] => 
                )

        )

    [from] => Array
        (
        )

    [index_hints] => 
    [partition] => 
    [where] => 
    [group] => 
    [having] => 
    [order] => 
    [limit] => 
    [procedure] => 
    [into] => 
    [join] => 
    [union] => Array
        (
        )

    [end_options] => 
    [options] => PhpMyAdmin\SqlParser\Components\OptionsArray Object
        (
            [options] => Array
                (
                )

        )

    [first] => 0
    [last] => 11
)
@williamdes
Copy link
Member

We should also support other parameters like :foo
I am sure there is some code about this somewhere
But the current code at phpMyAdmin web is not the best. See "link parameters" on the SQL query box

@williamdes
Copy link
Member

See: #202 and #253

@williamdes williamdes added the kind/support A request for adding support label Apr 21, 2023
MauricioFauth added a commit to MauricioFauth/sql-parser that referenced this issue Sep 26, 2023
- Fixes phpmyadmin#202
- Fixes phpmyadmin#412
- Fixes phpmyadmin#492
- Closes phpmyadmin#499
- Related to phpmyadmin#172

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
@MauricioFauth MauricioFauth self-assigned this Sep 27, 2023
@MauricioFauth MauricioFauth added this to the 5.9.0 milestone Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement kind/support A request for adding support
Projects
None yet
Development

No branches or pull requests

3 participants