Skip to content
Permalink
Browse files

Correctly generate IN clause placeholders.

This fixes logged queries not having placeholders replaced for IN clause
placeholders.

Refs cakephp/debug_kit#445
  • Loading branch information...
markstory committed Nov 25, 2016
1 parent a744f91 commit 3099d41da9af1c04b8c30e34720726363d212713
@@ -90,7 +90,7 @@ public function generateManyNamed($values, $type = 'string')
$this->_bindings[$param] = [
'value' => $value,
'type' => $type,
'placeholder' => $param
'placeholder' => substr($param, 1),
];
$placeholders[$k] = $param;
$this->_bindingsCount++;
@@ -72,7 +72,7 @@ public function testStringInterpolation()
*
* @return void
*/
public function testStringInterpolation2()
public function testStringInterpolationNotNamed()
{
$logger = $this->getMockBuilder('\Cake\Database\Log\QueryLogger')
->setMethods(['_log'])
@@ -92,7 +92,7 @@ public function testStringInterpolation2()
*
* @return void
*/
public function testStringInterpolation3()
public function testStringInterpolationDuplicate()
{
$logger = $this->getMockBuilder('\Cake\Database\Log\QueryLogger')
->setMethods(['_log'])
@@ -1367,6 +1367,26 @@ public function testInValueCast2()
$result->closeCursor();
}
/**
* Tests that IN clauses generate correct placeholders
*
* @return void
*/
public function testInClausePlaceholderGeneration()
{
$this->loadFixtures('Comments');
$query = new Query($this->connection);
$query->select(['id'])
->from('comments')
->where(['id IN' => [1, 2]])
->sql();
$bindings = $query->valueBinder()->bindings();
$this->assertArrayHasKey(':c0', $bindings);
$this->assertEquals('c0', $bindings[':c0']['placeholder']);
$this->assertArrayHasKey(':c1', $bindings);
$this->assertEquals('c1', $bindings[':c1']['placeholder']);
}
/**
* Tests where() with callable types.
*

0 comments on commit 3099d41

Please sign in to comment.
You can’t perform that action at this time.