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

Could not order by a formula when the formula was in the group by list but not in the select list.

上级 72a96f3b
...@@ -321,6 +321,8 @@ public abstract class Query extends Prepared { ...@@ -321,6 +321,8 @@ public abstract class Query extends Prepared {
throw Message.getSQLException(ErrorCode.ORDER_BY_NOT_IN_RESULT, e.getSQL()); throw Message.getSQLException(ErrorCode.ORDER_BY_NOT_IN_RESULT, e.getSQL());
} }
expressions.add(e); expressions.add(e);
String sql = e.getSQL();
expressionSQL.add(sql);
} }
o.expression = null; o.expression = null;
o.columnIndexExpr = ValueExpression.get(ValueInt.get(idx + 1)); o.columnIndexExpr = ValueExpression.get(ValueInt.get(idx + 1));
......
...@@ -570,8 +570,8 @@ public class Select extends Query { ...@@ -570,8 +570,8 @@ public class Select extends Query {
} }
private void expandColumnList() throws SQLException { private void expandColumnList() throws SQLException {
// TODO this works: select distinct count(*) from system_columns group // TODO this works: select distinct count(*)
// by table // from system_columns group by table
for (int i = 0; i < expressions.size(); i++) { for (int i = 0; i < expressions.size(); i++) {
Expression expr = (Expression) expressions.get(i); Expression expr = (Expression) expressions.get(i);
if (!expr.isWildcard()) { if (!expr.isWildcard()) {
......
create table t(d date) as select '2008-11-01' union select '2008-11-02';
select 1 from t group by year(d) order by year(d);
> 1;
drop table t;
create table t(d int) as select 2001 union select 2002;
select 1 from t group by d/10 order by d/10;
> 1;
drop table t;
create schema test; create schema test;
create sequence test.report_id_seq; create sequence test.report_id_seq;
select nextval('"test".REPORT_ID_SEQ'); select nextval('"test".REPORT_ID_SEQ');
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论