11package com .github .collinalpert .lambda2sql ;
22
3+ import com .github .collinalpert .expressions .expression .BinaryExpression ;
4+ import com .github .collinalpert .expressions .expression .ConstantExpression ;
5+ import com .github .collinalpert .expressions .expression .DelegateExpression ;
6+ import com .github .collinalpert .expressions .expression .Expression ;
7+ import com .github .collinalpert .expressions .expression .ExpressionType ;
8+ import com .github .collinalpert .expressions .expression .ExpressionVisitor ;
9+ import com .github .collinalpert .expressions .expression .InvocationExpression ;
10+ import com .github .collinalpert .expressions .expression .LambdaExpression ;
11+ import com .github .collinalpert .expressions .expression .MemberExpression ;
12+ import com .github .collinalpert .expressions .expression .ParameterExpression ;
13+ import com .github .collinalpert .expressions .expression .UnaryExpression ;
314import com .github .collinalpert .lambda2sql .functions .TriFunction ;
4- import com .trigersoft .jaque .expression .BinaryExpression ;
5- import com .trigersoft .jaque .expression .ConstantExpression ;
6- import com .trigersoft .jaque .expression .DelegateExpression ;
7- import com .trigersoft .jaque .expression .Expression ;
8- import com .trigersoft .jaque .expression .ExpressionType ;
9- import com .trigersoft .jaque .expression .ExpressionVisitor ;
10- import com .trigersoft .jaque .expression .InvocationExpression ;
11- import com .trigersoft .jaque .expression .LambdaExpression ;
12- import com .trigersoft .jaque .expression .MemberExpression ;
13- import com .trigersoft .jaque .expression .ParameterExpression ;
14- import com .trigersoft .jaque .expression .UnaryExpression ;
1515
1616import java .lang .reflect .Member ;
1717import java .time .LocalDate ;
@@ -130,15 +130,19 @@ public StringBuilder visit(BinaryExpression e) {
130130
131131 boolean quote = e != this .body && e .getExpressionType () == ExpressionType .LogicalOr ;
132132
133- if (quote ) sb .append ('(' );
133+ if (quote ) {
134+ sb .append ('(' );
135+ }
134136
135137 e .getFirst ().accept (this );
136138
137139 sb .append (' ' ).append (toSqlOperator (e .getExpressionType ())).append (' ' );
138140
139141 e .getSecond ().accept (this );
140142
141- if (quote ) sb .append (')' );
143+ if (quote ) {
144+ sb .append (')' );
145+ }
142146
143147 return sb ;
144148 }
@@ -201,7 +205,7 @@ public StringBuilder visit(InvocationExpression e) {
201205 * @return A {@link StringBuilder} containing the body of the lambda expression.
202206 */
203207 @ Override
204- public StringBuilder visit (LambdaExpression <?> e ) {
208+ public StringBuilder visit (LambdaExpression e ) {
205209 if (this .body == null && e .getBody () instanceof BinaryExpression ) {
206210 this .body = e .getBody ();
207211 }
@@ -308,6 +312,7 @@ private StringBuilder listContains(Expression listAsArgument, Expression argumen
308312 List l = (List ) arguments .pop ().get (((ParameterExpression ) listAsArgument ).getIndex ()).getValue ();
309313 var joiner = new StringJoiner (", " , "(" , ")" );
310314 l .forEach (x -> joiner .add (x .toString ()));
315+
311316 return argument .accept (new SqlVisitor (this .tableName , this .withBackticks , this .arguments )).append (negated ? " NOT" : "" ).append (" IN " ).append (joiner .toString ());
312317 }
313318
@@ -316,11 +321,11 @@ private StringBuilder listContains(Expression listAsArgument, Expression argumen
316321 private StringBuilder doStringOperation (Expression member , Expression argument , boolean negated , Consumer <StringBuilder > modifier ) {
317322 var valueBuilder = argument .accept (new SqlVisitor (this .tableName , this .withBackticks , this .arguments ));
318323 modifier .accept (valueBuilder );
324+
319325 return member .accept (new SqlVisitor (this .tableName , this .withBackticks , this .arguments )).append (negated ? " NOT" : "" ).append (" LIKE " ).append (valueBuilder );
320326 }
321327
322328 private String escapeString (String input ) {
323- input = input .replace ("\\ " , "\\ \\ " ).replace ("'" , "\\ '" );
324- return input ;
329+ return input .replace ("\\ " , "\\ \\ " ).replace ("'" , "\\ '" );
325330 }
326331}
0 commit comments