I am using exposed in one project, and I have a table lets call it TableX
with two properties
property1
and x
knowing that x
is nullable
I added TableX.x.isNotNull()
to my query so I can ignore null rows!.
And I have Object1
with also two properties as TableX
which are: property1
and x
knowing that x
is not null in Object1
Then when I create Object1 out of the rows from the query, the compiler will nag about x
because it should not be null and we are receiving a nullable x from TableX.
So I have added !!
when setting x
in Object1, given that I am sure that the query will never return any row with x is null
because of the constraint that I have added.
But still, I receive KotlinNullPointerException
some times. So how is this possible?
I thought of some compatibility issues between MySQL
and exposed
! But couldn't find any
val result = listOf<Object1>()
transaction {
val query = TableX.select {
TableX.property1.eq(123) and
TableX.x.isNotNull()
}
.fetchSize(1000)
result = query.map {
Object1(
property1 = it[TableX.property1],
x = it[TableX.x]!!
)
}
}