https://kotlinlang.org logo
#exposed
Title
# exposed
t

Timur Atakishiev

12/12/2019, 5:12 AM
Hi all, I got an expression like
Copy code
transaction {
    Restaurants.slice(Restaurants.followers.min(),Restaurants.id)
            .selectAll()
            .groupBy(Restaurants.id)
            .first()
}
and I have a simple mapper
Copy code
private fun toRestaurantUserName(row: ResultRow) = RestaurantUserNameDto(
        id = row[Restaurants.id],
        numberOfFollowers = row[Restaurants.followers.min()]!!
)
my question is when I want to fetch Restaurants.followers.min(), should I use
Copy code
row[Restaurants.followers.min()]!!
these one with double !!, or is it better way to write the code?Thank you
t

tapac

12/12/2019, 9:22 AM
It depends on you data. For example, if your
followers
column is nullable and you will run such query then you can get null as a result. Also, if you will call
min()
on a column which comes from a
left join
table you will face the same
null
value in a result row.
t

Timur Atakishiev

12/12/2019, 11:48 AM
Got you, thank you very much