Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #166 from K-Phoen/port-pr-266

Fix: port PR #266 from Propel
  • Loading branch information...
commit f0e005f347244ece1432e4d3aa37615dd459269c 2 parents c19c699 + 0090ac1
@willdurand willdurand authored
View
6 src/Propel/Runtime/Query/ModelCriteria.php
@@ -559,8 +559,10 @@ protected function configureSelectColumns()
return;
}
- // select() needs the SimpleArrayFormatter
- $this->setFormatter('\Propel\Runtime\Formatter\SimpleArrayFormatter');
+ // select() needs the PropelSimpleArrayFormatter if no formatter given
+ if (is_null($this->formatter)) {
+ $this->setFormatter('\Propel\Runtime\Formatter\SimpleArrayFormatter');
+ }
// clear only the selectColumns, clearSelectColumns() clears asColumns too
$this->selectColumns = array();
View
11 tests/Propel/Tests/Runtime/Query/ModelCriteriaSelectTest.php
@@ -412,4 +412,15 @@ public function testGetSelectReturnsArrayWhenSelectingAllColumns()
'Propel\Tests\Bookstore\Book.AuthorId'
), $c->getSelect());
}
+
+ public function testFormatterWithSelect()
+ {
+ $c = new ModelCriteria('bookstore', 'Propel\Tests\Bookstore\Book');
+ $c->keepQuery(false); // just for this test's purpose
+ $c->setFormatter(ModelCriteria::FORMAT_ON_DEMAND);
+ $c->select(array('Id', 'Title'));
+ $rows = $c->find($this->con);
+
+ $this->assertTrue($c->getFormatter() instanceof \Propel\Runtime\Formatter\OnDemandFormatter, 'The formatter is preserved');
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.