Merge branch 'master' into 2.6

This commit is contained in:
mark_story 2014-11-14 21:25:09 -05:00
commit decce4daf2
6 changed files with 140 additions and 91 deletions

View file

@ -518,4 +518,46 @@ class SqliteTest extends CakeTestCase {
$this->assertNotContains($scientificNotation, $result);
}
/**
* Test that fields are parsed out in a reasonable fashion.
*
* @return void
*/
public function testFetchRowColumnParsing() {
$this->loadFixtures('User');
$sql = 'SELECT "User"."id", "User"."user", "User"."password", "User"."created", (1 + 1) AS "two" ' .
'FROM "users" AS "User" WHERE ' .
'"User"."id" IN (SELECT MAX("id") FROM "users") ' .
'OR "User.id" IN (5, 6, 7, 8)';
$result = $this->Dbo->fetchRow($sql);
$expected = array(
'User' => array(
'id' => 4,
'user' => 'garrett',
'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
'created' => '2007-03-17 01:22:23'
),
0 => array(
'two' => 2
)
);
$this->assertEquals($expected, $result);
$sql = 'SELECT "User"."id", "User"."user" ' .
'FROM "users" AS "User" WHERE "User"."id" = 4 ' .
'UNION ' .
'SELECT "User"."id", "User"."user" ' .
'FROM "users" AS "User" WHERE "User"."id" = 3';
$result = $this->Dbo->fetchRow($sql);
$expected = array(
'User' => array(
'id' => 3,
'user' => 'larry',
),
);
$this->assertEquals($expected, $result);
}
}