Browse Source

REPORT-111169 数据集含有注释的参数,但参数依然生效

release/11.0
Yuan.Wang 11 months ago
parent
commit
1e09143a00
  1. 14
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java
  2. 41
      designer-base/src/test/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPaneTest.java

14
designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java

@ -61,6 +61,7 @@ import com.fr.stable.ArrayUtils;
import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext;
import org.jetbrains.annotations.NotNull;
import javax.swing.BorderFactory;
import javax.swing.Box;
@ -416,10 +417,7 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> implemen
}
private void checkParameter() {
String[] paramTexts = new String[2];
paramTexts[0] = SqlUtils.clearSqlComments(this.sqlTextPane.getText());
paramTexts[1] = SqlUtils.clearSqlComments(this.pageQuery);
Parameter[] parameters = ParameterHelper.analyze4Parameters(paramTexts, false);
Parameter[] parameters = getParameters();
if (parameters.length < 1 && this.editorPane.update().size() < 1) {
return;
@ -443,6 +441,14 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> implemen
refreshParameters();
}
@NotNull
private Parameter[] getParameters() {
String[] paramTexts = new String[2];
paramTexts[0] = SqlUtils.clearSqlComments(this.sqlTextPane.getText());
paramTexts[1] = SqlUtils.clearSqlComments(this.pageQuery);
return ParameterHelper.analyze4Parameters(paramTexts, false);
}
@Override
public void populateBean(DBTableData dbTableData) {
this.dbTableData = dbTableData;

41
designer-base/src/test/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPaneTest.java

@ -0,0 +1,41 @@
package com.fr.design.data.tabledata.tabledatapane;
import com.fr.base.Parameter;
import com.fr.design.data.datapane.sqlpane.SQLEditPane;
import com.fr.invoke.Reflect;
import junit.framework.TestCase;
import org.junit.Assert;
/**
* @author Yuan.Wang
* @since 11.0
* Created on 2023/12/22
*/
public class DBTableDataPaneTest extends TestCase {
public void testGetParameters() {
DBTableDataPane pane = new DBTableDataPane();
SQLEditPane editPane = new SQLEditPane();
String sql = "select distinct 类别ID from S产品\n" +
"where 1=1\n" +
"order by 类别ID\n" +
"--${ if(len(comboBox0) = 0,\"\",\"AND 类别00ID = '\" + comboBox0 + \"'\")}";
String sql1 = "select distinct 类别ID from S产品\n" +
"where 1=1\n" +
"order by 类别ID\n" +
"${ if(len(comboBox0) = 0,\"\",\"AND 类别00ID = '\" + comboBox0 + \"'\")}";
editPane.setText(sql);
Reflect.on(pane).set("sqlTextPane", editPane);
Reflect.on(pane).set("pageQuery", sql);
Parameter[] parameters = Reflect.on(pane).call("getParameters").get();
Assert.assertEquals(0, parameters.length);
editPane.setText(sql1);
parameters = Reflect.on(pane).call("getParameters").get();
Assert.assertEquals(1, parameters.length);
Assert.assertEquals(parameters[0].getName(), "comboBox0");
}
}
Loading…
Cancel
Save