I've recentyly started using Room and I would like to know if when inserting or updating an Entitiy there's any way to check if the value is null, and in that case, do not insert it /update it.
What I want to do is something like
@Entity
data class Person{
@PrimaryKey
val id: Int,
val name:String
val surname:String
}
Would it be possible in a simple way to perform an @Update operation for those fields which are not null? and those which are null keep them as tey are?
For example in an update perhaps I might have informed the id and the name, but in another update I might have informed the id and the surname. So what I want is to merge the information, but if possible without having to make a select query to check the values stored.
I've read the following post, but my doubt then it would be, is it possible to define an @Entity, with all the fields defined as the one I mentioned before and then have other entities to just update some fields, something like:
@Entity(tableName = "person")
data class PersonUpdateSurname{
@PrimaryKey
val id: Int,
val name:String
}
@Entity(tableName = "person")
data class PersonUpdateSurname{
@PrimaryKey
val id: Int,
val surname:String
}
Is there a way to tell Room which is the original table structure?