Skip to content

Commit a03ab7f

Browse files
committed
Rewrite for code coverage
1 parent 03e11b8 commit a03ab7f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main/kotlin/org/mybatis/dynamic/sql/util/kotlin/KotlinSubQueryBuilders.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import org.mybatis.dynamic.sql.SqlBuilder
2020
import org.mybatis.dynamic.sql.SqlColumn
2121
import org.mybatis.dynamic.sql.select.SelectModel
2222
import org.mybatis.dynamic.sql.util.Buildable
23+
import java.lang.NullPointerException
2324

2425
@MyBatisDslMarker
2526
sealed class KotlinBaseSubQueryBuilder : Buildable<SelectModel> {
@@ -40,7 +41,11 @@ sealed class KotlinBaseSubQueryBuilder : Buildable<SelectModel> {
4041
}
4142

4243
override fun build(): SelectModel =
43-
selectBuilder?.build()?: throw KInvalidSQLException("You must specify a select statement in a sub query")
44+
try {
45+
selectBuilder!!.build()
46+
} catch (e: NullPointerException) {
47+
throw KInvalidSQLException("You must specify a select statement in a sub query")
48+
}
4449
}
4550

4651
class KotlinSubQueryBuilder : KotlinBaseSubQueryBuilder()

0 commit comments

Comments
 (0)