Commit 068febde authored by Dries's avatar Dries

- Patch #327271 by hswong3i, Crell: proper use of AS keyword so it works on PostgreSQL and Oracle.

parent 7142e3fe
......@@ -673,6 +673,8 @@ public function __toString() {
// FIELDS and EXPRESSIONS
$fields = array();
foreach ($this->fields as $alias => $field) {
// Always use the AS keyword for field aliases, as some
// databases require it (e.g., PostgreSQL).
$fields[] = (isset($field['table']) ? $field['table'] . '.' : '') . $field['field'] . ' AS ' . $field['alias'];
}
foreach ($this->expressions as $alias => $expression) {
......@@ -693,7 +695,9 @@ public function __toString() {
if (isset($table['join type'])) {
$query .= $table['join type'] . ' JOIN ';
}
$query .= '{' . $this->connection->escapeTable($table['table']) . '} AS ' . $table['alias'];
// Don't use the AS keyword for table aliases, as some
// databases don't support it (e.g., Oracle).
$query .= '{' . $this->connection->escapeTable($table['table']) . '} ' . $table['alias'];
if (!empty($table['condition'])) {
$query .= ' ON ' . $table['condition'];
}
......
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