|
1 | 1 | /*
|
2 |
| - * Copyright 2016-2020 the original author or authors. |
| 2 | + * Copyright 2016-2021 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
21 | 21 | import static org.mybatis.dynamic.sql.SqlBuilder.*;
|
22 | 22 |
|
23 | 23 | import java.sql.JDBCType;
|
| 24 | +import java.util.Collection; |
24 | 25 | import java.util.Collections;
|
25 | 26 | import java.util.Date;
|
26 | 27 | import java.util.List;
|
@@ -370,4 +371,48 @@ void testNotInCaseInsensitiveWhenPresentEmptyList() {
|
370 | 371 | selectModel.render(RenderingStrategies.MYBATIS3)
|
371 | 372 | ).withMessage("Fred");
|
372 | 373 | }
|
| 374 | + |
| 375 | + @Test |
| 376 | + void testInWhenPresentNullList() { |
| 377 | + SelectStatementProvider selectStatement = select(column1, column3) |
| 378 | + .from(table) |
| 379 | + .where(column3, isInWhenPresent((Collection<String>) null)) |
| 380 | + .build() |
| 381 | + .render(RenderingStrategies.MYBATIS3); |
| 382 | + |
| 383 | + assertThat(selectStatement.getSelectStatement()).isEqualTo("select column1, column3 from foo"); |
| 384 | + } |
| 385 | + |
| 386 | + @Test |
| 387 | + void testInCaseInsensitiveWhenPresentNullList() { |
| 388 | + SelectStatementProvider selectStatement = select(column1, column3) |
| 389 | + .from(table) |
| 390 | + .where(column3, isInCaseInsensitiveWhenPresent((Collection<String>) null)) |
| 391 | + .build() |
| 392 | + .render(RenderingStrategies.MYBATIS3); |
| 393 | + |
| 394 | + assertThat(selectStatement.getSelectStatement()).isEqualTo("select column1, column3 from foo"); |
| 395 | + } |
| 396 | + |
| 397 | + @Test |
| 398 | + void testNotInWhenPresentNullList() { |
| 399 | + SelectStatementProvider selectStatement = select(column1, column3) |
| 400 | + .from(table) |
| 401 | + .where(column3, isNotInWhenPresent((Collection<String>) null)) |
| 402 | + .build() |
| 403 | + .render(RenderingStrategies.MYBATIS3); |
| 404 | + |
| 405 | + assertThat(selectStatement.getSelectStatement()).isEqualTo("select column1, column3 from foo"); |
| 406 | + } |
| 407 | + |
| 408 | + @Test |
| 409 | + void testNotInCaseInsensitiveWhenPresentNullList() { |
| 410 | + SelectStatementProvider selectStatement = select(column1, column3) |
| 411 | + .from(table) |
| 412 | + .where(column3, isNotInCaseInsensitiveWhenPresent((Collection<String>) null)) |
| 413 | + .build() |
| 414 | + .render(RenderingStrategies.MYBATIS3); |
| 415 | + |
| 416 | + assertThat(selectStatement.getSelectStatement()).isEqualTo("select column1, column3 from foo"); |
| 417 | + } |
373 | 418 | }
|
0 commit comments