I have a really weird issue, I have run the debugger and step through the code to see each element from Firestore
I have a list of products at my firestore database
Structure
shop -> shopId -> products -> productList
I have a data class as following
@Parcelize
data class Producto(
val imagenProducto: String = "",
val nombreProducto: String = "",
val descProducto: String = "",
val precio: Int = 0,
val hasDescuento: Boolean = false,
val tipoDescuento: Double = 0.0,
val isCombo: Boolean = false
) : Parcelable
And now the code I use to filter by isCombo
to create two lists that one will contain all the products (with a discount if needed) and combos (if the isCombo
boolean is set to true)
Now, this is weird, because my code fetches all these documents and sends it to my view
suspend fun getProductosList(comercioId:String):Resource<MutableList<Producto>>{
val productList = mutableListOf<Producto>()
val snapshot = FirebaseFirestore.getInstance().collection("comercios").document(comercioId).collection("products").get().await()
for(producto in snapshot){
productList.add(producto.toObject(Producto::class.java))
}
return Resource.Success(productList)
}
Here I have a subcollection where the final products of a shop (comercio) are.
Problem
So, here is what it happens, after I fetch all these documents, the list comes to my view with the data of each element of the list, but one value of the product does not come as espected.
I have place in one document isCombo = true
but when this comes to my app, it places this value as false but the other boolean hasDescuento
comes with the right value
What I have tried
- clean and rebuild
- invalidate cache / restart
- step through with the debugger to see each element see if I was inserting my variable with a typo
- check my reference to the data
Here are the outputs, this is how I have the data stored at my reference
here isCombo
is set to true
Now, this is what ends up in my view when retrieving this document
So, here isCombo
comes to false, but my other boolean hasDescuento comes with the right value from the database (for another different product), I was suspecting about the Parcelize annotation in my data class, but all the other data that's not isCombo is fetched normally
What could happen ?