forked from github/dataease
fix(数据集): SQL数据集参数会把between等条件丢失
This commit is contained in:
parent
d915775007
commit
43cb2c2190
@ -2594,38 +2594,62 @@ public class DataSetTableService {
|
|||||||
visitBinaryExpr(andExpression, "AND");
|
visitBinaryExpr(andExpression, "AND");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void visit(Between between) {
|
||||||
|
if(hasVarible(between.getBetweenExpressionStart().toString()) || hasVarible(between.getBetweenExpressionEnd().toString())){
|
||||||
|
getBuffer().append(SubstitutedSql);
|
||||||
|
}else {
|
||||||
|
getBuffer().append(between.getLeftExpression()).append(" BETWEEN ").append(between.getBetweenExpressionStart()).append(" AND ").append(between.getBetweenExpressionEnd());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(MinorThan minorThan) {
|
public void visit(MinorThan minorThan) {
|
||||||
|
if(hasVarible(minorThan.getLeftExpression().toString()) || hasVarible(minorThan.getRightExpression().toString())){
|
||||||
|
getBuffer().append(SubstitutedSql);
|
||||||
|
return;
|
||||||
|
}
|
||||||
getBuffer().append(minorThan.getLeftExpression());
|
getBuffer().append(minorThan.getLeftExpression());
|
||||||
getBuffer().append(" < ");
|
getBuffer().append(" < ");
|
||||||
getBuffer().append(minorThan.getRightExpression());
|
getBuffer().append( minorThan.getRightExpression());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(MinorThanEquals minorThan) {
|
public void visit(MinorThanEquals minorThan) {
|
||||||
|
if(hasVarible(minorThan.getLeftExpression().toString()) || hasVarible(minorThan.getRightExpression().toString())){
|
||||||
|
getBuffer().append(SubstitutedSql);
|
||||||
|
return;
|
||||||
|
}
|
||||||
getBuffer().append(minorThan.getLeftExpression());
|
getBuffer().append(minorThan.getLeftExpression());
|
||||||
getBuffer().append(" <= ");
|
getBuffer().append(" <= ");
|
||||||
getBuffer().append(minorThan.getRightExpression());
|
getBuffer().append( minorThan.getRightExpression());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(GreaterThanEquals minorThan) {
|
public void visit(GreaterThanEquals minorThan) {
|
||||||
|
if(hasVarible(minorThan.getLeftExpression().toString()) || hasVarible(minorThan.getRightExpression().toString())){
|
||||||
|
getBuffer().append(SubstitutedSql);
|
||||||
|
return;
|
||||||
|
}
|
||||||
getBuffer().append(minorThan.getLeftExpression());
|
getBuffer().append(minorThan.getLeftExpression());
|
||||||
getBuffer().append(" >= ");
|
getBuffer().append(" >= ");
|
||||||
getBuffer().append(minorThan.getRightExpression());
|
getBuffer().append( minorThan.getRightExpression());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(GreaterThan minorThan) {
|
public void visit(GreaterThan greaterThan) {
|
||||||
getBuffer().append(minorThan.getLeftExpression());
|
if(hasVarible(greaterThan.getLeftExpression().toString()) || hasVarible(greaterThan.getRightExpression().toString())){
|
||||||
|
getBuffer().append(SubstitutedSql);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
getBuffer().append(greaterThan.getLeftExpression());
|
||||||
getBuffer().append(" > ");
|
getBuffer().append(" > ");
|
||||||
getBuffer().append(minorThan.getRightExpression());
|
getBuffer().append( greaterThan.getRightExpression());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(ExpressionList expressionList) {
|
public void visit(ExpressionList expressionList) {
|
||||||
for (Iterator<Expression> iter = expressionList.getExpressions().iterator(); iter.hasNext(); ) {
|
for (Iterator<Expression> iter = expressionList.getExpressions().iterator(); iter.hasNext();) {
|
||||||
Expression expression = iter.next();
|
Expression expression = iter.next();
|
||||||
expression.accept(this);
|
expression.accept(this);
|
||||||
if (iter.hasNext()) {
|
if (iter.hasNext()) {
|
||||||
@ -2634,15 +2658,6 @@ public class DataSetTableService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void visit(Between between) {
|
|
||||||
if (hasVarible(between.getBetweenExpressionStart().toString()) || hasVarible(between.getBetweenExpressionEnd().toString())) {
|
|
||||||
getBuffer().append(SubstitutedSql);
|
|
||||||
} else {
|
|
||||||
getBuffer().append(between.getLeftExpression()).append(" BETWEEN ").append(between.getBetweenExpressionStart()).append(" AND ").append(between.getBetweenExpressionEnd());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(LikeExpression likeExpression) {
|
public void visit(LikeExpression likeExpression) {
|
||||||
if (hasVarible(likeExpression.toString())) {
|
if (hasVarible(likeExpression.toString())) {
|
||||||
@ -2706,31 +2721,27 @@ public class DataSetTableService {
|
|||||||
|
|
||||||
|
|
||||||
private void visitBinaryExpr(BinaryExpression expr, String operator) {
|
private void visitBinaryExpr(BinaryExpression expr, String operator) {
|
||||||
boolean hasBinaryExpression = false;
|
boolean hasSubBinaryExpression = false;
|
||||||
try {
|
try {
|
||||||
BinaryExpression leftBinaryExpression = (BinaryExpression) expr.getLeftExpression();
|
BinaryExpression leftBinaryExpression = (BinaryExpression) expr.getLeftExpression();
|
||||||
hasBinaryExpression = leftBinaryExpression.getLeftExpression() instanceof BinaryExpression;
|
hasSubBinaryExpression = leftBinaryExpression.getLeftExpression() instanceof Expression;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {e.printStackTrace();}
|
||||||
}
|
|
||||||
|
|
||||||
if (expr.getLeftExpression() instanceof BinaryExpression && !hasBinaryExpression && hasVarible(expr.getLeftExpression().toString())) {
|
if (expr.getLeftExpression() instanceof BinaryExpression && !hasSubBinaryExpression && hasVarible(expr.getLeftExpression().toString())) {
|
||||||
getBuffer().append(SubstitutedSql);
|
getBuffer().append(SubstitutedSql);
|
||||||
} else {
|
} else {
|
||||||
expr.getLeftExpression().accept(this);
|
expr.getLeftExpression().accept(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
getBuffer().append(" " + operator + " ");
|
getBuffer().append(" " + operator + " ");
|
||||||
|
hasSubBinaryExpression = false;
|
||||||
hasBinaryExpression = false;
|
|
||||||
try {
|
try {
|
||||||
BinaryExpression rightBinaryExpression = (BinaryExpression) expr.getRightExpression();
|
BinaryExpression rightBinaryExpression = (BinaryExpression) expr.getRightExpression();
|
||||||
hasBinaryExpression = rightBinaryExpression.getRightExpression() instanceof BinaryExpression;
|
hasSubBinaryExpression = rightBinaryExpression.getRightExpression() instanceof BinaryExpression;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
|
if (expr.getRightExpression() instanceof BinaryExpression && !hasSubBinaryExpression && hasVarible(expr.getRightExpression().toString())) {
|
||||||
if (expr.getRightExpression() instanceof BinaryExpression && !hasBinaryExpression && hasVarible(expr.getRightExpression().toString())) {
|
|
||||||
getBuffer().append(SubstitutedSql);
|
|
||||||
} else if (expr.getRightExpression() instanceof InExpression && !hasBinaryExpression && hasVarible(expr.getRightExpression().toString())) {
|
|
||||||
getBuffer().append(SubstitutedSql);
|
getBuffer().append(SubstitutedSql);
|
||||||
} else {
|
} else {
|
||||||
expr.getRightExpression().accept(this);
|
expr.getRightExpression().accept(this);
|
||||||
|
Loading…
Reference in New Issue
Block a user