diff --git a/src/ORM/DataQuery.php b/src/ORM/DataQuery.php index e403f90b3..f953aca35 100644 --- a/src/ORM/DataQuery.php +++ b/src/ORM/DataQuery.php @@ -1147,6 +1147,7 @@ class DataQuery { $fieldExpression = $this->expressionForField($field); $query = $this->getFinalisedQuery(array($field)); + $query->setDistinct(false); $originalSelect = $query->getSelect(); $query->setSelect(array()); $query->selectField($fieldExpression, $field); diff --git a/tests/php/ORM/DataQueryTest.php b/tests/php/ORM/DataQueryTest.php index b9278a496..8f2b2a3fd 100644 --- a/tests/php/ORM/DataQueryTest.php +++ b/tests/php/ORM/DataQueryTest.php @@ -379,4 +379,22 @@ class DataQueryTest extends SapphireTest $this->assertEquals('Last', $second['Title']); $this->assertEmpty(array_shift($arrayResult)); } + + public function testColumnReturnsAllValues() + { + $first = new DataQueryTest\ObjectA(); + $first->Name = 'Bar'; + $first->write(); + + $second = new DataQueryTest\ObjectA(); + $second->Name = 'Foo'; + $second->write(); + + $third = new DataQueryTest\ObjectA(); + $third->Name = 'Bar'; + $third->write(); + + $result = DataQueryTest\ObjectA::get()->column('Name'); + $this->assertEquals(['Bar', 'Foo', 'Bar'], $result); + } }