File tree Expand file tree Collapse file tree 4 files changed +9
-10
lines changed
main/java/com/github/collinalpert/lambda2sql
test/java/com/github/collinalpert/lambda2sql/test Expand file tree Collapse file tree 4 files changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ You can include the Maven dependency:
5656<dependency >
5757 <groupId >com.github.collinalpert</groupId >
5858 <artifactId >lambda2sql</artifactId >
59- <version >1.8.2 </version >
59+ <version >1.8.3 </version >
6060</dependency >
6161```
6262
Original file line number Diff line number Diff line change 66
77 <groupId >com.github.collinalpert</groupId >
88 <artifactId >lambda2sql</artifactId >
9- <version >1.8.2 </version >
9+ <version >1.8.3 </version >
1010 <packaging >jar</packaging >
1111
1212 <name >lambda2sql</name >
Original file line number Diff line number Diff line change @@ -66,13 +66,7 @@ public StringBuilder visit(BinaryExpression e) {
6666 if (quote ) sb .append ('(' );
6767
6868 e .getFirst ().accept (this );
69- sb .append (' ' );
70- if (!arguments .isEmpty () && arguments .top ().get (0 ).getValue () == null ) {
71- sb .append ("IS" );
72- } else {
73- sb .append (toSqlOp (e .getExpressionType ()));
74- }
75- sb .append (' ' );
69+ sb .append (' ' ).append (toSqlOp (e .getExpressionType ())).append (' ' );
7670 e .getSecond ().accept (this );
7771
7872 if (quote ) sb .append (')' );
@@ -90,7 +84,9 @@ public StringBuilder visit(BinaryExpression e) {
9084 @ Override
9185 public StringBuilder visit (ConstantExpression e ) {
9286 if (e .getValue () == null ) {
93- return sb .append ("NULL" );
87+ sb .deleteCharAt (sb .length () - 1 );
88+ sb .delete (sb .lastIndexOf (" " ), sb .length ());
89+ return sb .append (" IS NULL" );
9490 }
9591 if (e .getValue () instanceof String ) {
9692 return sb .append ("'" ).append (e .getValue ().toString ()).append ("'" );
Original file line number Diff line number Diff line change @@ -87,10 +87,13 @@ void testNestedProperties() {
8787 @ Test
8888 void testNull () {
8989 String isNull = null ;
90+ Integer i = null ;
9091 SqlPredicate <IPerson > p = person -> person .getName () == isNull ;
9192 SqlPredicate <IPerson > p2 = person -> person .getName () == null ;
93+ SqlPredicate <IPerson > p3 = person -> person .getAge () >= i ;
9294 assertPredicateEqual ("person.name IS NULL" , p );
9395 assertPredicateEqual ("person.name IS NULL" , p2 );
96+ assertPredicateEqual ("person.age IS NULL" , p3 );
9497 }
9598
9699 private void assertPredicateEqual (String expectedSql , SqlPredicate <IPerson > p ) {
You can’t perform that action at this time.
0 commit comments