30
30
import java .sql .Connection ;
31
31
import java .sql .DriverManager ;
32
32
import java .util .List ;
33
- import java .util .Objects ;
34
33
35
34
import org .apache .ibatis .datasource .unpooled .UnpooledDataSource ;
36
35
import org .apache .ibatis .jdbc .ScriptRunner ;
@@ -94,26 +93,6 @@ void testAllIgnored() {
94
93
}
95
94
}
96
95
97
- @ Test
98
- void testSelectByNull () {
99
- // this method demonstrates that ignoring the null value warning will still work
100
- try (SqlSession sqlSession = sqlSessionFactory .openSession ()) {
101
- AnimalDataMapper mapper = sqlSession .getMapper (AnimalDataMapper .class );
102
- SelectStatementProvider selectStatement = select (id , animalName , bodyWeight , brainWeight )
103
- .from (animalData )
104
- .where (id , isGreaterThan (NULL_INTEGER )) // should be an IDE warning about passing null to a nonnull method
105
- .orderBy (id )
106
- .build ()
107
- .render (RenderingStrategies .MYBATIS3 );
108
- List <AnimalData > animals = mapper .selectMany (selectStatement );
109
- assertAll (
110
- () -> assertThat (selectStatement .getSelectStatement ()).isEqualTo ("select id, animal_name, body_weight, brain_weight from AnimalData where id > #{parameters.p1,jdbcType=INTEGER} order by id" ),
111
- () -> assertThat (selectStatement .getParameters ()).containsEntry ("p1" , null ),
112
- () -> assertThat (animals ).isEmpty ()
113
- );
114
- }
115
- }
116
-
117
96
@ Test
118
97
void testIgnoredBetweenRendered () {
119
98
try (SqlSession sqlSession = sqlSessionFactory .openSession ()) {
@@ -122,7 +101,7 @@ void testIgnoredBetweenRendered() {
122
101
.from (animalData )
123
102
.where (id , isEqualTo (3 ))
124
103
.and (id , isNotEqualToWhenPresent (NULL_INTEGER ))
125
- .or (id , isEqualTo (4 ). filter ( Objects :: nonNull ) )
104
+ .or (id , isEqualTo (4 ))
126
105
.orderBy (id )
127
106
.build ()
128
107
.render (RenderingStrategies .MYBATIS3 );
@@ -143,8 +122,8 @@ void testIgnoredInWhere() {
143
122
SelectStatementProvider selectStatement = select (id , animalName , bodyWeight , brainWeight )
144
123
.from (animalData )
145
124
.where (id , isLessThanWhenPresent (NULL_INTEGER ))
146
- .and (id , isEqualTo (3 ). filter ( Objects :: nonNull ) )
147
- .or (id , isEqualTo (4 ). filter ( Objects :: nonNull ) )
125
+ .and (id , isEqualTo (3 ))
126
+ .or (id , isEqualTo (4 ))
148
127
.orderBy (id )
149
128
.build ()
150
129
.render (RenderingStrategies .MYBATIS3 );
@@ -187,8 +166,8 @@ void testIgnoredInitialWhere() {
187
166
AnimalDataMapper mapper = sqlSession .getMapper (AnimalDataMapper .class );
188
167
SelectStatementProvider selectStatement = select (id , animalName , bodyWeight , brainWeight )
189
168
.from (animalData )
190
- .where (id , isLessThanWhenPresent (NULL_INTEGER ), and (id , isEqualTo (3 ). filter ( Objects :: nonNull ) ))
191
- .or (id , isEqualTo (4 ). filter ( Objects :: nonNull ) )
169
+ .where (id , isLessThanWhenPresent (NULL_INTEGER ), and (id , isEqualTo (3 )))
170
+ .or (id , isEqualTo (4 ))
192
171
.orderBy (id )
193
172
.build ()
194
173
.render (RenderingStrategies .MYBATIS3 );
@@ -802,7 +781,7 @@ void testIsLikeWhenWithValue() {
802
781
AnimalDataMapper mapper = sqlSession .getMapper (AnimalDataMapper .class );
803
782
SelectStatementProvider selectStatement = select (id , animalName , bodyWeight , brainWeight )
804
783
.from (animalData )
805
- .where (animalName , isLike ("%mole" ). filter ( Objects :: nonNull ) )
784
+ .where (animalName , isLike ("%mole" ))
806
785
.and (id , isLessThanOrEqualTo (10 ))
807
786
.orderBy (id )
808
787
.build ()
@@ -882,7 +861,7 @@ void testIsNotLikeWhenWithValue() {
882
861
AnimalDataMapper mapper = sqlSession .getMapper (AnimalDataMapper .class );
883
862
SelectStatementProvider selectStatement = select (id , animalName , bodyWeight , brainWeight )
884
863
.from (animalData )
885
- .where (animalName , isNotLike ("%mole" ). filter ( Objects :: nonNull ) )
864
+ .where (animalName , isNotLike ("%mole" ))
886
865
.and (id , isLessThanOrEqualTo (10 ))
887
866
.orderBy (id )
888
867
.build ()
0 commit comments