https://kotlinlang.org logo
#room
Title
v

Vivek Sharma

01/10/2022, 4:43 PM
I have a question, when I have entity like this:
Copy code
@Entity
data class Note(
    val title: String,
    val content: String,
    val timestamp: Long,
    val color: Int,
    @PrimaryKey val id: Int? = null
)
and when I create Note object, and passing 
null
  to 
id
 , what room will assign to it? In my case it is assigning 
1, 2, 3, 4...
  like it is autoGenerating, is this correct what I am thinking? Though I am NOT having
autoGenerate = true
in
@PrimaryKey
y

yigit

01/25/2022, 4:51 PM
hmm, primary key cannot be null so we should maybe throwing here instead of generating it. Well pkey can technically be null but sqlite consider it a bug. Can you file a bug on the issue tracker so the team can take a look at it ?
v

Vivek Sharma

01/25/2022, 6:37 PM
okay filed
4 Views