Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix: port PR #266 from Propel #166

Merged
merged 1 commit into from

2 participants

@K-Phoen

Propel2 issue: #133 and original PR https://github.com/propelorm/Propel/pull/266/files

I also added a test :)

@willdurand
Owner

Awesome! Thanks, really.

@willdurand willdurand merged commit f0e005f into propelorm:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 30, 2012
  1. @K-Phoen

    Fix: port PR #266 from Propel

    K-Phoen authored
This page is out of date. Refresh to see the latest.
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');
+ }
}
Something went wrong with that request. Please try again.