Skip to content

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

@KacerCZ

Description

@KacerCZ

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions