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

BC break in 3.1 handling "IN (?)" in query #273

Closed
KacerCZ opened this issue Mar 16, 2021 · 2 comments
Closed

BC break in 3.1 handling "IN (?)" in query #273

KacerCZ opened this issue Mar 16, 2021 · 2 comments

Comments

@KacerCZ
Copy link

KacerCZ commented Mar 16, 2021

Version: 3.1.1

Bug Description

I tried to upgrade from 3.0.7 to 3.1.1 and found incompatibility in handling "IN (?)".
For simplicity in code I don't examine if array has single value or more values and I always insert placeholders with count matching values in array and then pass arguments to query.

Usually generated query looks like select name from table where id in (?,?,?) and parameters are [ 1, 2, 3 ].
If parameters contain single value then this bug appears, becasue query is select name from table where id in (?) and parameters are [ 1 ].

Steps To Reproduce

Use following code:

$database = new \Nette\Database\Connection(...);
$database->queryArgs( 'select name from table where id in (?)', [ 1 ] );

Exception with message "Placeholder ?list expects array or Traversable object, integer given" is thrown.
This snippet passed in older versions.

Expected Behavior

Query will pass as it did in 3.0.7 and older versions.

Possible Solution

Correctly handle case with single scalar value in parameters.

@dg
Copy link
Member

dg commented Mar 16, 2021

fixed

@dg dg closed this as completed Mar 16, 2021
@KacerCZ
Copy link
Author

KacerCZ commented Mar 17, 2021

I tested the fix and it works.
Thank you for prompt response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants