Unverified 提交 cf11224f authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov 提交者: GitHub

Merge pull request #1024 from katzyn/webconsole

Improve sorting in web console
...@@ -21,6 +21,10 @@ Change Log ...@@ -21,6 +21,10 @@ Change Log
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul> <ul>
<li>Issue #1019: Console incorrectly sorts BigDecimal columns alphanumerically
</li>
<li>PR #1021: Update JdbcDatabaseMetaData to JDBC 4.1 (Java 7)
</li>
<li>Issue #992: 1.4.196+ client cannot use DatabaseMetaData with 1.4.195- server <li>Issue #992: 1.4.196+ client cannot use DatabaseMetaData with 1.4.195- server
</li> </li>
<li>Issue #1016: ResultSet.getObject() should return enum value, not ordinal <li>Issue #1016: ResultSet.getObject() should return enum value, not ordinal
......
...@@ -163,6 +163,10 @@ function getInnerText(el) { ...@@ -163,6 +163,10 @@ function getInnerText(el) {
return str; return str;
} }
function isNullCell(td) {
return td.childNodes.length == 1 && (td.childNodes[0].nodeName == "I");
}
function resortTable(link) { function resortTable(link) {
// get the span // get the span
var span; var span;
...@@ -175,26 +179,39 @@ function resortTable(link) { ...@@ -175,26 +179,39 @@ function resortTable(link) {
var td = link.parentNode; var td = link.parentNode;
var column = td.cellIndex; var column = td.cellIndex;
var table = getParent(td,'TABLE'); var table = getParent(td,'TABLE');
var rows = table.rows;
if (table.rows.length <= 1) return; if (rows.length <= 1) return;
// detect sort type // detect sort type
var sortNumeric = false; var sortNumeric = true;
var x = getInnerText(table.rows[1].cells[column]); for (i = 1; i < rows.length; i++) {
if (x.match(/^[\d\.]+$/)) { var td = rows[i].cells[column];
sortNumeric = true; if (!isNullCell(td)) {
var x = getInnerText(td);
// H2 does not return numeric values with leading +, but may return
// values in scientific notation
if (!x.match(/^\-?\d*\.?\d+(?:[Ee][\+\-]?\d+)?$/)) {
sortNumeric = false;
break;
}
}
} }
var newRows = new Array(); var newRows = new Array();
var rows = table.rows;
for (i=1; i<rows.length; i++) { for (i=1; i<rows.length; i++) {
var o = new Object(); var o = new Object();
o.data = rows[i]; o.data = rows[i];
o.id = i; o.id = i;
var td = o.data.cells[column];
var n = isNullCell(td);
o.isNull = n;
if (!n) {
var txt = getInnerText(td);
if (sortNumeric) { if (sortNumeric) {
o.sort = parseFloat(getInnerText(o.data.cells[column])); o.sort = parseFloat(txt);
if (isNaN(o.sort)) o.sort = 0; if (isNaN(o.sort)) o.sort = 0;
} else { } else {
o.sort = getInnerText(o.data.cells[column]); o.sort = txt;
}
} }
newRows[i-1] = o; newRows[i-1] = o;
} }
...@@ -240,6 +257,10 @@ function getParent(el, pTagName) { ...@@ -240,6 +257,10 @@ function getParent(el, pTagName) {
} }
function sortCallback(ra, rb) { function sortCallback(ra, rb) {
if (ra.isNull) {
return rb.isNull ? (ra.id - rb.id) : -1;
} else if (rb.IsNull) {
return 1;
}
return (ra.sort==rb.sort) ? (ra.id-rb.id) : (ra.sort<rb.sort ? -1 : 1); return (ra.sort==rb.sort) ? (ra.id-rb.id) : (ra.sort<rb.sort ? -1 : 1);
} }
...@@ -771,4 +771,4 @@ openoffice organize libre systemtables gmane sea borders announced millennium al ...@@ -771,4 +771,4 @@ openoffice organize libre systemtables gmane sea borders announced millennium al
opti excessively opti excessively
iterators tech enums incompatibilities loses reimplement readme reorganize milli subdirectory linkplain inspections iterators tech enums incompatibilities loses reimplement readme reorganize milli subdirectory linkplain inspections
geometries sourceschema destschema generatedcolumn geometries sourceschema destschema generatedcolumn alphanumerically
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论