Commit a407037d authored by alexpott's avatar alexpott

Issue #2795967 by daffie, Katiemouse: A query with a...

Issue #2795967 by daffie, Katiemouse: A query with a fetchAll(\PDO::FETCH_COLUMN) will fail for SQLite
parent 380e763f
...@@ -306,7 +306,7 @@ public function current() { ...@@ -306,7 +306,7 @@ public function current() {
return $this->fetchOptions['object']; return $this->fetchOptions['object'];
case \PDO::FETCH_COLUMN: case \PDO::FETCH_COLUMN:
if (isset($this->columnNames[$this->fetchOptions['column']])) { if (isset($this->columnNames[$this->fetchOptions['column']])) {
return $this->currentRow[$k][$this->columnNames[$this->fetchOptions['column']]]; return $this->currentRow[$this->columnNames[$this->fetchOptions['column']]];
} }
else { else {
return; return;
......
...@@ -113,6 +113,19 @@ function testQueryFetchBoth() { ...@@ -113,6 +113,19 @@ function testQueryFetchBoth() {
$this->assertIdentical(count($records), 1, 'There is only one record.'); $this->assertIdentical(count($records), 1, 'There is only one record.');
} }
/**
* Confirms that we can fetch all records into an array explicitly.
*/
public function testQueryFetchAllColumn() {
$query = db_select('test');
$query->addField('test', 'name');
$query->orderBy('name');
$query_result = $query->execute()->fetchAll(\PDO::FETCH_COLUMN);
$expected_result = ['George', 'John', 'Paul', 'Ringo'];
$this->assertEqual($query_result, $expected_result, 'Returned the correct result.');
}
/** /**
* Confirms that we can fetch an entire column of a result set at once. * Confirms that we can fetch an entire column of a result set at once.
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment