Skip to content

Commit

Permalink
Add tests for less greedy field parsing in SQLite.
Browse files Browse the repository at this point in the history
Refs #6887
  • Loading branch information
markstory committed Jun 26, 2015
1 parent 0b28c2e commit e651d15
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php
Expand Up @@ -560,4 +560,30 @@ public function testFetchRowColumnParsing() {
$this->assertEquals($expected, $result);
}

/**
* Test parsing more complex field names.
*
* @return void
*/
public function testFetchColumnRowParsingMoreComplex()
{
$this->loadFixtures('User');
$sql = 'SELECT
COUNT(*) AS User__count,
COUNT(CASE id WHEN 2 THEN 1 ELSE NULL END) as User__case,
AVG(CAST("User"."id" AS BIGINT)) AS User__bigint
FROM "users" AS "User"
WHERE "User"."id" > 0';
$result = $this->Dbo->fetchRow($sql);

$expected = array(
'0' => array(
'User__count' => '4',
'User__case' => '1',
'User__bigint' => '2.5',
),
);
$this->assertEquals($expected, $result);
}

}

0 comments on commit e651d15

Please sign in to comment.