Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix][common]Support 'BETWEEN AND' query condition parameter parsing … #1973

Merged
merged 1 commit into from
Dec 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,7 @@
import net.sf.jsqlparser.expression.Function;
import net.sf.jsqlparser.expression.LongValue;
import net.sf.jsqlparser.expression.StringValue;
import net.sf.jsqlparser.expression.operators.relational.ComparisonOperator;
import net.sf.jsqlparser.expression.operators.relational.EqualsTo;
import net.sf.jsqlparser.expression.operators.relational.ExpressionList;
import net.sf.jsqlparser.expression.operators.relational.GreaterThan;
import net.sf.jsqlparser.expression.operators.relational.GreaterThanEquals;
import net.sf.jsqlparser.expression.operators.relational.InExpression;
import net.sf.jsqlparser.expression.operators.relational.LikeExpression;
import net.sf.jsqlparser.expression.operators.relational.MinorThan;
import net.sf.jsqlparser.expression.operators.relational.MinorThanEquals;
import net.sf.jsqlparser.expression.operators.relational.*;
import net.sf.jsqlparser.schema.Column;
import org.apache.commons.collections.CollectionUtils;

Expand All @@ -34,6 +26,29 @@ public FieldAndValueAcquireVisitor(Set<FieldExpression> fieldExpressions) {
this.fieldExpressions = fieldExpressions;
}

public void visit(Between between) {
Expression leftExpression = between.getLeftExpression();
String columnName = null;
if (leftExpression instanceof Column) {
Column column = (Column) leftExpression;
columnName = column.getColumnName();
}
Expression betweenExpressionStart = between.getBetweenExpressionStart();
Expression betweenExpressionEnd = between.getBetweenExpressionEnd();

FieldExpression fieldExpressionStart = new FieldExpression();
fieldExpressionStart.setFieldName(columnName);
fieldExpressionStart.setFieldValue(getFieldValue(betweenExpressionStart));
fieldExpressionStart.setOperator(JsqlConstants.GREATER_THAN_EQUALS);
fieldExpressions.add(fieldExpressionStart);

FieldExpression fieldExpressionEnd = new FieldExpression();
fieldExpressionEnd.setFieldName(columnName);
fieldExpressionEnd.setFieldValue(getFieldValue(betweenExpressionEnd));
fieldExpressionEnd.setOperator(JsqlConstants.MINOR_THAN_EQUALS);
fieldExpressions.add(fieldExpressionEnd);
}

public void visit(LikeExpression expr) {
Expression leftExpression = expr.getLeftExpression();
Expression rightExpression = expr.getRightExpression();
Expand Down
Loading