Issue #3346898 by mondrake, alexpott: Remove obsolete code from Drupal\sqlite\Driver\Database\sqlite\Statement
parent
90897afee0
commit
057996416b
|
@ -106,45 +106,6 @@ class Statement extends StatementPrefetch implements StatementInterface {
|
|||
}
|
||||
}
|
||||
|
||||
// In some weird cases, SQLite will prefix some column names by the name
|
||||
// of the table. We post-process the data, by renaming the column names
|
||||
// using the same convention as MySQL and PostgreSQL.
|
||||
$rename_columns = [];
|
||||
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];
|
||||
}
|
||||
}
|
||||
if ($rename_columns) {
|
||||
// DatabaseStatementPrefetch already extracted the first row,
|
||||
// put it back into the result set.
|
||||
if (isset($this->currentRow)) {
|
||||
$this->data[0] = &$this->currentRow;
|
||||
}
|
||||
|
||||
// Then rename all the columns across the result set.
|
||||
foreach ($this->data as $k => $row) {
|
||||
foreach ($rename_columns as $old_column => $new_column) {
|
||||
$this->data[$k][$new_column] = $this->data[$k][$old_column];
|
||||
unset($this->data[$k][$old_column]);
|
||||
}
|
||||
}
|
||||
|
||||
// Finally, extract the first row again.
|
||||
$this->currentRow = $this->data[0];
|
||||
unset($this->data[0]);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue