Skip to content

Commit

Permalink
[DoctrineBridge] Fix issue which prevent the profiler to explain a query
Browse files Browse the repository at this point in the history
  • Loading branch information
Baachi authored and fabpot committed Oct 28, 2015
1 parent c7e772c commit 3490e98
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
Expand Up @@ -117,6 +117,9 @@ private function sanitizeQueries($connectionName, $queries)
private function sanitizeQuery($connectionName, $query)
{
$query['explainable'] = true;
if (null === $query['params']) {
$query['params'] = array();
}
if (!is_array($query['params'])) {
$query['params'] = array($query['params']);
}
Expand Down
Expand Up @@ -79,9 +79,25 @@ public function testCollectQueries($param, $types, $expected, $explainable)
$c = $this->createCollector($queries);
$c->collect(new Request(), new Response());

$collected_queries = $c->getQueries();
$this->assertEquals($expected, $collected_queries['default'][0]['params'][0]);
$this->assertEquals($explainable, $collected_queries['default'][0]['explainable']);
$collectedQueries = $c->getQueries();
$this->assertEquals($expected, $collectedQueries['default'][0]['params'][0]);
$this->assertEquals($explainable, $collectedQueries['default'][0]['explainable']);
}

public function testCollectQueryWithNoParams()
{
$queries = array(
array('sql' => 'SELECT * FROM table1', 'params' => array(), 'types' => array(), 'executionMS' => 1),
array('sql' => 'SELECT * FROM table1', 'params' => null, 'types' => null, 'executionMS' => 1),
);
$c = $this->createCollector($queries);
$c->collect(new Request(), new Response());

$collectedQueries = $c->getQueries();
$this->assertEquals(array(), $collectedQueries['default'][0]['params']);
$this->assertTrue($collectedQueries['default'][0]['explainable']);
$this->assertEquals(array(), $collectedQueries['default'][1]['params']);
$this->assertTrue($collectedQueries['default'][1]['explainable']);
}

/**
Expand All @@ -96,9 +112,9 @@ public function testSerialization($param, $types, $expected, $explainable)
$c->collect(new Request(), new Response());
$c = unserialize(serialize($c));

$collected_queries = $c->getQueries();
$this->assertEquals($expected, $collected_queries['default'][0]['params'][0]);
$this->assertEquals($explainable, $collected_queries['default'][0]['explainable']);
$collectedQueries = $c->getQueries();
$this->assertEquals($expected, $collectedQueries['default'][0]['params'][0]);
$this->assertEquals($explainable, $collectedQueries['default'][0]['explainable']);
}

public function paramProvider()
Expand Down

0 comments on commit 3490e98

Please sign in to comment.