File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change 33import com .trigersoft .jaque .expression .*;
44
55import java .util .ArrayList ;
6+ import java .util .List ;
67
78import static com .trigersoft .jaque .expression .ExpressionType .*;
89
910public class ToSqlVisitor implements ExpressionVisitor <StringBuilder > {
1011
1112 private StringBuilder sb = new StringBuilder ();
1213 private Expression body ;
13- private ArrayList <ConstantExpression > parameters = new ArrayList <>();
14+ private List <ConstantExpression > parameters = new ArrayList <>();
1415
1516 private static String toSqlOp (int expressionType ) {
1617 switch (expressionType ) {
@@ -20,6 +21,8 @@ private static String toSqlOp(int expressionType) {
2021 return "AND" ;
2122 case LogicalOr :
2223 return "OR" ;
24+ case Convert :
25+ return "" ;
2326 }
2427 return ExpressionType .toString (expressionType );
2528 }
@@ -76,7 +79,7 @@ public StringBuilder visit(ParameterExpression e) {
7679
7780 @ Override
7881 public StringBuilder visit (UnaryExpression e ) {
79- sb .append (ExpressionType . toString (e .getExpressionType ()));
82+ sb .append (toSqlOp (e .getExpressionType ()));
8083 return e .getFirst ().accept (this );
8184 }
8285
Original file line number Diff line number Diff line change @@ -31,7 +31,10 @@ public void testMultipleLogicalOps() {
3131 @ Test
3232 public void testWithVariables () {
3333 String name = "Donald" ;
34- assertEqual ("name = 'Donald'" , person -> person .getName () == name );
34+ //Datatype must be "Integer" for now. This is due to a bug in the JaQue library and author has been notified.
35+ //As soon as the bug is fixed, the test will be updated.
36+ Integer age = 80 ;
37+ assertEqual ("name = 'Donald' AND age > 80" , person -> person .getName () == name && person .getAge () > age );
3538 }
3639
3740 private void assertEqual (String expectedSql , SqlPredicate <Person > p ) {
You can’t perform that action at this time.
0 commit comments