I'm not an expert when it comes to Room and SQLite on android. But I would like to share my own observations and findings with this issue.
@P.Leibner is right that LiveData object itself is returned immediately and it is not null. The content might be null.
If you look at generated code of Dao, you will see it is a Java code and it will return null if there are no records matching your query. Also there are no annotations that would help Kotlin compiler to check for nullability.
Therefore, we don't get compiler error or lint warnings if we return non-null object
// Compiles but we might get NullPointerException at runtime.
fun getGoldStatus(): LiveData<GoldStatus>
// or
fun getGoldStatus(): GoldStatus
But you are going to run into NullPointerExceptions at runtime if you don't have a row in table and start doing something with that object if you mark it as non-null in Kotlin.
Note: this won't happen if you return List<GoldStatus> or LiveData<List<GoldStatus>>. it will just return empty list if there are no rows matching.
I didn't know this myself until I run into these problems. Maybe I missed some explanations when learning about room. We just have to know that room will return object or null if you are querying single row and list or empty list if multiple rows.
I prefer specifying nullability in return type of Dao method. This way I write other code that works with it in null safe way.
I would call this one Code C
// Runtime NullPointerException safe.
fun getGoldStatus(): LiveData<GoldStatus?>
// or
fun getGoldStatus(): GoldStatus?
You can also look at this answer to get more info and see example of generated code by Dao.