提交 31119540 authored 作者: Thomas Mueller's avatar Thomas Mueller

Group by with a quoted select column name alias didn't work. Example: select 1…

Group by with a quoted select column name alias didn't work. Example: select 1 "a" from dual group by "a" 
上级 2e98e3f4
...@@ -783,6 +783,11 @@ public class Select extends Query { ...@@ -783,6 +783,11 @@ public class Select extends Query {
found = j; found = j;
break; break;
} }
sql = expr.getAlias();
if (db.equalsIdentifiers(sql, e.getAlias())) {
found = j;
break;
}
} }
} }
if (found < 0) { if (found < 0) {
......
...@@ -249,7 +249,7 @@ public class ExpressionColumn extends Expression { ...@@ -249,7 +249,7 @@ public class ExpressionColumn extends Expression {
@Override @Override
public String getAlias() { public String getAlias() {
return column == null ? null : column.getName(); return column == null ? columnName : column.getName();
} }
@Override @Override
......
...@@ -3,6 +3,11 @@ ...@@ -3,6 +3,11 @@
-- Initial Developer: H2 Group -- Initial Developer: H2 Group
-- --
--- special grammar and test cases --------------------------------------------------------------------------------------------- --- special grammar and test cases ---------------------------------------------------------------------------------------------
select 1 "a", count(*) from dual group by "a" order by "a";
> a COUNT(*)
> - --------
> 1 1
> rows (ordered): 1
create table results(eventId int, points int, studentId int); create table results(eventId int, points int, studentId int);
> ok > ok
...@@ -6413,8 +6418,8 @@ EXPLAIN SELECT * FROM TEST WHERE (ID>=1 AND ID<=2) OR (ID>0 AND ID<3) AND (ID<> ...@@ -6413,8 +6418,8 @@ EXPLAIN SELECT * FROM TEST WHERE (ID>=1 AND ID<=2) OR (ID>0 AND ID<3) AND (ID<>
EXPLAIN SELECT * FROM TEST WHERE ID=1 GROUP BY NAME, ID; EXPLAIN SELECT * FROM TEST WHERE ID=1 GROUP BY NAME, ID;
> PLAN > PLAN
> ------------------------------------------------------------------------------------------------------------ > ----------------------------------------------------------------------------------------------------------------------
> SELECT TEST.ID, TEST.NAME FROM PUBLIC.TEST /* PUBLIC.PRIMARY_KEY_2: ID = 1 */ WHERE ID = 1 GROUP BY NAME, ID > SELECT TEST.ID, TEST.NAME FROM PUBLIC.TEST /* PUBLIC.PRIMARY_KEY_2: ID = 1 */ WHERE ID = 1 GROUP BY TEST.NAME, TEST.ID
> rows: 1 > rows: 1
EXPLAIN PLAN FOR UPDATE TEST SET NAME='Hello', ID=1 WHERE NAME LIKE 'T%' ESCAPE 'x'; EXPLAIN PLAN FOR UPDATE TEST SET NAME='Hello', ID=1 WHERE NAME LIKE 'T%' ESCAPE 'x';
...@@ -10125,3 +10130,4 @@ create table test(id int, name varchar); ...@@ -10125,3 +10130,4 @@ create table test(id int, name varchar);
insert into test values(5, 'b'), (5, 'b'), (20, 'a'); insert into test values(5, 'b'), (5, 'b'), (20, 'a');
> update count: 3 > update count: 3
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论