set "dontCount" if row-count get wrong

This commit is contained in:
Ralf Wisser
2024-06-22 14:46:44 +02:00
parent e8b046f2e4
commit 9785d0ead4
4 changed files with 29 additions and 2 deletions
@@ -2129,6 +2129,8 @@ public class UIUtil {
hiddenWindows.clear();
}
// TODO
// TODO offer only flat lafs (light, dark). Don't offer Nimbus and Native
public static enum PLAF {
FLAT("Flat", true), NIMBUS("Nimbus", false), NATIVE("Native", false), FLATDARK("FlatDark", true);
@@ -5693,6 +5693,13 @@ public class DataBrowser extends javax.swing.JFrame implements ConnectionTypeCha
List<Row> parentRows = rowBrowser.browserContentPane.parentRows;
if (rowBrowser.browserContentPane.association != null && parentRows != null
&& !parentRows.isEmpty()) {
wcEditor.setDontCount(rowBrowser.browserContentPane.selectDistinctCheckBox.isVisible()
&& rowBrowser.browserContentPane.selectDistinctCheckBox.isEnabled()
&& rowBrowser.browserContentPane.selectDistinctCheckBox.isSelected());
// TODO
// TODO ? dontCount if #parentRows > 50?
String cond;
String unrestrictedJoinCondition = rowBrowser.browserContentPane.association
.getUnrestrictedJoinCondition();
@@ -6970,3 +6977,6 @@ public class DataBrowser extends javax.swing.JFrame implements ConnectionTypeCha
// TODO
// TODO nach oeffnen aus extrModelEditor heraus: TableDetailsView links unten verdeckt (JSplitPane.dividerPos nicht korrekt)
// TODO
// TODO connection-tree on the left: gradient-painting of dev-test-prod-connections is ugly
@@ -277,7 +277,8 @@ public class DesktopOutline extends JPanel {
g2d.setColor(inDesktopColor);
paint = new GradientPaint(
0, 0, UIUtil.plaf == PLAF.FLATDARK? new Color(30, 35, 44) : Colors.Color_255_255_255,
gw, gh, inDesktopColor);
gw, gh, UIUtil.plaf == PLAF.FLATDARK? inDesktopColor.darker() : inDesktopColor); // TODO
// TODO alles scharz?!
g2d.setPaint(paint);
g2d.setStroke(stroke);
g2d.fillRoundRect(sx, sy, sw, sh, 8, 8);
@@ -2249,6 +2249,7 @@ public abstract class WhereConditionEditorPanel extends javax.swing.JPanel {
columnName = tableAlias + "." + columnName;
tabName += " " + tableAlias;
}
String sqlQuery;
String tableWithCondition = createTableWithCondition(condition, tabName, extJoin);
String cte = getCTE().trim();
@@ -2258,7 +2259,7 @@ public abstract class WhereConditionEditorPanel extends javax.swing.JPanel {
if (inSQLConsole()) {
sqlQuery = cte + "Select val, count(1) from (Select " + columnName + " val From " + tableWithCondition + ") Q group by val";
} else {
sqlQuery = cte + "Select " + columnName + ", count(1) from " + tableWithCondition + " group by " + columnName;
sqlQuery = cte + "Select " + columnName + ", " + (dontCount? "0" : "count(1)") + " from " + tableWithCondition + " group by " + columnName;
}
AbstractResultSetReader reader = new AbstractResultSetReader() {
@Override
@@ -2682,10 +2683,23 @@ public abstract class WhereConditionEditorPanel extends javax.swing.JPanel {
constraintPKIcon = UIUtil.scaleIcon(new JLabel(""), UIUtil.readImage("/constraint_pk.png"));
okIcon = UIUtil.readImage("/buttonok.png");
}
private boolean dontCount = false;
public void setDontCount(boolean dontCount) {
this.dontCount = dontCount;
}
// TODO support properties
// TODO multi-value-select? (in clause?)
// TODO
// TODO multi-block "row-count" aggregation:
// TODO try reduce block-limit to 1. Test if rowcounts are always correct.
// TODO
// TODO status quo: no row-counts visible if "distinct"-checkbox is selected (and visible)
// TODO that maybe doesn't work! Because multiple queries takes place if there are a lot of parents!
// TODO loadDistinctValues: counts "non-distinct"-rows: use "where exists(Select from B where <joinCond> and <B.Pk1=x or B.Pk=y ...>"
// TODO instead of "join"
// TODO ? only if "select distinct"-checkbox is selected? (yes. check caching!)