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

When using order by in a query that uses the same table multiple times, the…

When using order by in a query that uses the same table multiple times, the order could be incorrect.
上级 21563c94
...@@ -372,11 +372,11 @@ public class Select extends Query { ...@@ -372,11 +372,11 @@ public class Select extends Query {
if (!(expr instanceof ExpressionColumn)) { if (!(expr instanceof ExpressionColumn)) {
return null; return null;
} }
Column col = ((ExpressionColumn) expr).getColumn(); ExpressionColumn exprCol = (ExpressionColumn) expr;
if (col.getTable() != topTableFilter.getTable()) { if (exprCol.getTableFilter() != topTableFilter) {
return null; return null;
} }
sortColumns.add(col); sortColumns.add(exprCol.getColumn());
} }
Column[] sortCols = new Column[sortColumns.size()]; Column[] sortCols = new Column[sortColumns.size()];
sortColumns.toArray(sortCols); sortColumns.toArray(sortCols);
...@@ -887,6 +887,9 @@ public class Select extends Query { ...@@ -887,6 +887,9 @@ public class Select extends Query {
if (isDistinctQuery) { if (isDistinctQuery) {
buff.append("\n/* distinct */"); buff.append("\n/* distinct */");
} }
if (sortUsingIndex) {
buff.append("\n/* index sorted */");
}
if (isGroupQuery) { if (isGroupQuery) {
if (isGroupSortedQuery) { if (isGroupSortedQuery) {
buff.append("\n/* group sorted */"); buff.append("\n/* group sorted */");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论