#340568 by Damien Tournoud: in some versions of SQLite, SELECT DISINCT(field) will return '(field)' as the field name.

merge-requests/26/head
Angie Byron 2008-11-30 01:26:45 +00:00
parent d6514fe3aa
commit aa4b94fcc9
1 changed files with 9 additions and 0 deletions

View File

@ -238,6 +238,15 @@ class DatabaseStatement_sqlite extends DatabaseStatementPrefetch implements Iter
// using the same convention as MySQL and PostgreSQL.
$rename_columns = array();
foreach ($this->columnNames as $k => $column) {
// In some SQLite versions, SELECT DISTINCT(field) will return "(field)"
// instead of "field".
if (preg_match("/^\((.*)\)$/", $column, $matches)) {
$rename_columns[$column] = $matches[1];
$this->columnNames[$k] = $matches[1];
$column = $matches[1];
}
// Remove "table." prefixes.
if (preg_match("/^.*\.(.*)$/", $column, $matches)) {
$rename_columns[$column] = $matches[1];
$this->columnNames[$k] = $matches[1];