Skip to content
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

Incorrect handling of list parameters with sparse types #2897

Closed
morozov opened this issue Oct 25, 2017 · 2 comments
Closed

Incorrect handling of list parameters with sparse types #2897

morozov opened this issue Oct 25, 2017 · 2 comments
Assignees
Milestone

Comments

@morozov
Copy link
Member

morozov commented Oct 25, 2017

When a list parameter is bound to a query but the previous parameter types are omitted, the query gets processed incorrectly.

Steps to reproduce:

$query = 'SELECT NULL FROM dummy WHERE ? IN (?)';
$params = ['foo', ['foo', 'bar']];
$types = [1 => Connection::PARAM_STR_ARRAY];

list($query, $params, $types) = SQLParserUtils::expandListParameters($query, $params, $types);

Expected result:

$query = 'SELECT NULL FROM dummy WHERE ? IN (?, ?)';
$params = ['foo', 'foo', 'bar'];
$types = [null, PDO::PARAM_STR, PDO::PARAM_STR];

Actual result:

Warning: array_merge(): Argument #2 is not an array in lib/Doctrine/DBAL/SQLParserUtils.php on line 136

$query = 'SELECT NULL FROM dummy WHERE ? IN (?)'; // not modified, invalid
$params = null; // invalid
$types = [PDO::PARAM_STR]; // invalid
@morozov
Copy link
Member Author

morozov commented Mar 16, 2020

Closed via #3894.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant