@@ -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