Fix merge regressions / errors

This commit is contained in:
Damian Mooyman 2015-06-02 20:19:12 +12:00
parent 8331171f2c
commit 51df4df9f1
3 changed files with 10 additions and 5 deletions

View File

@ -298,7 +298,7 @@ class FixtureBlueprint {
DB::manipulate(array( DB::manipulate(array(
$table => array( $table => array(
"command" => "update", "id" => $obj->ID, "command" => "update", "id" => $obj->ID,
"fields" => array($fieldName => is_string($value) ? "'$value'" : $value) "fields" => array($fieldName => $value)
) )
)); ));
$obj->$fieldName = $value; $obj->$fieldName = $value;

View File

@ -576,8 +576,13 @@ class SQLSelect extends SQLConditionalExpression {
* @return int * @return int
*/ */
public function count( $column = null) { public function count( $column = null) {
// we can't clear the select if we're relying on its output by a HAVING clause
if(!empty($this->having)) {
$records = $this->execute();
return $records->numRecords();
}
// Choose a default column // Choose a default column
if($column == null) { elseif($column == null) {
if($this->groupby) { if($this->groupby) {
$column = 'DISTINCT ' . implode(", ", $this->groupby); $column = 'DISTINCT ' . implode(", ", $this->groupby);
} else { } else {

View File

@ -596,7 +596,7 @@ class SQLQueryTest extends SapphireTest {
public function testSelect() { public function testSelect() {
$query = new SQLQuery('"Title"', '"MyTable"'); $query = new SQLQuery('"Title"', '"MyTable"');
$query->addSelect('"TestField"'); $query->addSelect('"TestField"');
$this->assertEquals( $this->assertSQLEquals(
'SELECT "Title", "TestField" FROM "MyTable"', 'SELECT "Title", "TestField" FROM "MyTable"',
$query->sql() $query->sql()
); );
@ -606,7 +606,7 @@ class SQLQueryTest extends SapphireTest {
'Field' => '"Field"', 'Field' => '"Field"',
'AnotherAlias' => '"AnotherField"' 'AnotherAlias' => '"AnotherField"'
)); ));
$this->assertEquals( $this->assertSQLEquals(
'SELECT "Field", "AnotherField" AS "AnotherAlias" FROM "MyTable"', 'SELECT "Field", "AnotherField" AS "AnotherAlias" FROM "MyTable"',
$query->sql() $query->sql()
); );
@ -615,7 +615,7 @@ class SQLQueryTest extends SapphireTest {
$query->addSelect(array( $query->addSelect(array(
'Relevance' => "MATCH (Title, MenuTitle) AGAINST ('Two as One')" 'Relevance' => "MATCH (Title, MenuTitle) AGAINST ('Two as One')"
)); ));
$this->assertEquals( $this->assertSQLEquals(
'SELECT "Field", "AnotherField" AS "AnotherAlias", MATCH (Title, MenuTitle) AGAINST (' . 'SELECT "Field", "AnotherField" AS "AnotherAlias", MATCH (Title, MenuTitle) AGAINST (' .
'\'Two as One\') AS "Relevance" FROM "MyTable"', '\'Two as One\') AS "Relevance" FROM "MyTable"',
$query->sql() $query->sql()