title: Can't Update Room database item
body: <p>I'm trying to update a column of an item in a room database but the item isn't updating.</p>
  
  <p>My Entity:</p>
  
  <pre><code>    @Entity(tableName = "order_summary_table")
      data class SummaryItem(
      @ColumnInfo(name = "quantity")
      var quantity: Int = -1,
  
      @ColumnInfo(name = "item_name")
      val name: String,
  
      @ColumnInfo(name = "item_price")
      var price: Int
      ) {
      @PrimaryKey(autoGenerate = true)
      var itemId: Long = 0
      }
  </code></pre>
  
  <p>Here is my Dao:</p>
  
  <pre><code>    @Update
      fun update(summaryItem: SummaryItem)
  
      @Query("SELECT * FROM order_summary_table WHERE itemId = :key")
      suspend fun get(key: Long): SummaryItem?
  </code></pre>
  
  <p>Function in the ViewModel. I'm using Kotlin Coroutines for database operations. My database has 3 columns: quantity, name and price. Here I wrote a function to update the quantity column of an item in the database:</p>
  
  <pre><code>   fun saveEditedItem(quantity: Int, summaryItemKey: Long) {
        coroutineScope.launch {
             val item = database.get(summaryItemKey)
             val editedItem = SummaryItem(quantity, item!!.name, item.price)
             updateSummaryItem(editedItem)
         }
     }
  
     private suspend fun updateSummaryItem(summaryItem: SummaryItem) {
        withContext(Dispatchers.IO) {
            database.update(summaryItem)
        }
     }
  </code></pre>
  
  <p>Fragment.kt file, Here I set an OnClickListener to update the item on button click but the item isn't getting updated.</p>
  
  <pre><code>   val quantityText = binding.editQuantityText
     binding.saveButton.setOnClickListener {
          val editTextValue = quantityText.text
          val quantity = Integer.parseInt(editTextValue.toString())
          viewModel.saveEditedItem(quantity, arguments.summaryItemKey)
     }
  </code></pre>