💾 A database layer with a familiar PDO-like API but much more powerful. Building queries, advanced joins, drivers for MySQL, PostgreSQL, SQLite, MS SQL Server and Oracle.
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.
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 isselect name from table where id in (?)
and parameters are[ 1 ]
.Steps To Reproduce
Use following code:
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.