Permalink
Browse files

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

Fix: port PR #266 from Propel
  • Loading branch information...
2 parents c19c699 + 0090ac1 commit f0e005f347244ece1432e4d3aa37615dd459269c @willdurand willdurand committed Mar 30, 2012
@@ -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();
@@ -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');
+ }
}

0 comments on commit f0e005f

Please sign in to comment.