Skip to content

Commit c41535d

Browse files
author
phosco@gmx.de
committed
CHG: the base_expr of a select-expression contains now an explicit alias (with "as"). Check your client code!
git-svn-id: https://php-sql-parser.googlecode.com/svn/trunk@1351 44dcfd11-89b7-3d55-2063-5c365055f77f
1 parent 7677e78 commit c41535d

1 file changed

Lines changed: 10 additions & 12 deletions

File tree

src/PHPSQLParser/processors/SelectExpressionProcessor.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ public function process($expression) {
104104
$base_expr .= $token;
105105
}
106106

107+
if ($alias) {
108+
// remove quotation from the alias
109+
$alias['no_quotes'] = $this->revokeQuotation($alias['name']);
110+
$alias['name'] = trim($alias['name']);
111+
$alias['base_expr'] = trim($alias['base_expr']);
112+
}
113+
107114
$stripped = $this->processExpressionList($stripped);
108115

109116
// TODO: the last part can also be a comment, don't use array_pop
@@ -127,26 +134,17 @@ public function process($expression) {
127134
'base_expr' => trim($last['base_expr']));
128135
// remove the last token
129136
array_pop($tokens);
130-
$base_expr = join("", $tokens);
131137
}
132138
}
133139

134-
if (!$alias) {
135-
$base_expr = join("", $tokens);
136-
} else {
137-
/* remove escape from the alias */
138-
$alias['no_quotes'] = $this->revokeQuotation($alias['name']);
139-
$alias['name'] = trim($alias['name']);
140-
$alias['base_expr'] = trim($alias['base_expr']);
141-
}
142-
140+
$base_expr = $expression;
141+
143142
// TODO: this is always done with $stripped, how we do it twice?
144143
$processed = $this->processExpressionList($tokens);
145144

146145
// if there is only one part, we copy the expr_type
147-
// in all other cases we use "expression" as global type
146+
// in all other cases we use "EXPRESSION" as global type
148147
$type = ExpressionType::EXPRESSION;
149-
150148
if (count($processed) === 1) {
151149
if (!$this->isSubQuery($processed[0])) {
152150
$type = $processed[0]['expr_type'];

0 commit comments

Comments
 (0)