Entities in Backlink ToMany reappearing after removing
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
Línea de trabajo
Comienza con la reproducción en Kotlin y app/src/main/java/com/mobilecomputing/collit/data/datasource/LocalImageDataSource.kt, centrándote en ToMany.removeById, applyChangesToDb y Box.put. Reproduce ambos órdenes de eliminación y sigue la actualización de la relación. Se considera terminado cuando la Property eliminada no vuelve a aparecer después de guardar el objeto padre, independientemente del orden de las operaciones.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
When trying to remove entities from a One-To-Many relationship, they keep reappearing in the database after put() when first removing from the relationship and afterwards from box
Basic info (please complete the following information):
- ObjectBox version: 3.1.0
- Reproducibility: always
- Device: Galaxy S10 (Android 11), OnePlus 6T (Android 11), Pixel 4 (Android 12)
- OS: Android 11 and 12
To Reproduce
Steps to reproduce the behavior:
- Create 2 entities with a 1:N relationship (
oneandmany) - Add some entities to the ToMany (
many) of the other (one). - Remove 1 entity from the relationship with
one.many.removeById(id) - Remove the entity from the box
box.remove(id) - Put the parent (
one) in the box again (overriding it)
Expected behavior
No matter the order, if an entity gets deleted from the box and the relation and is nowhere to be found, it should not reappear in the box.
Code
My Repo
Example code where I tested the issue in a Kotlin project
fun main(args: Array<String>) {
val store: BoxStore = MyObjectBox.builder().name("objectbox-notes-db").build()
val imageBox = store.boxFor<Image>().also { it.removeAll() }
val propertyBox = store.boxFor<Property>().also { it.removeAll() }
val originalImage = Image()
imageBox.put(originalImage)
originalImage.apply {
properties.addAll(listOf(
Property(name = "h1"),
Property(name = "h2"),
Property(name = "h3")
))
}
imageBox.put(originalImage)
println("Boxed Properties: " + propertyBox.all.map { it.id })
println("Original Image Properties: " + originalImage.properties.map { it.id })
val removedID = propertyBox.all.first().id
println("Removing id ${removedID}")
val image = imageBox.get(originalImage.id).also {
it.properties.removeById(removedID) //changing the order of these 2 will make
propertyBox.remove(propertyBox.all.first().id) // it work as expected
it.properties.applyChangesToDb()
}
println("--------------")
println("Both houldn't have ${removedID}: ")
println("Boxed Properties before put: " + propertyBox.all.map { it.id })
println("New Image Properties before put: " + image.properties.map { it.id })
imageBox.put(image)
println("--------------")
println("Should still not have ${removedID}")
println("Boxed Properties after put: " + propertyBox.all.map { it.id })
println("New Image Properties after put: " + image.properties.map { it.id })
}
@Entity
data class Image(
@Id
var id: Long = 0,
....
) {
@Backlink(to = "image")
lateinit var properties: ToMany<Property>
}
@Entity
data class Property(
@Id
var id: Long = 0,
..
) {
lateinit var image: ToOne<Image>
}
Additional context
Flipping the order (e.g. first removing the entity from the box) and THEN removing it from the ToMany works.
- Lenguaje dominante
- Java
- Estrellas
- 4.6k
- Forks
- 311
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de objectbox/objectbox-java
-
bug
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
objectbox/objectbox-java#1226 · 2 comentarios ·
-
documentation enhancement
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
objectbox/objectbox-java#1225 · 9 comentarios · 1 reacción ·
-
enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
objectbox/objectbox-java#1223 · 1 comentario · 4 reacciones ·
-
enhancement
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
objectbox/objectbox-java#1211 · 1 comentario · 3 reacciones ·
-
bug
Dificultad 3/5 1-2 días Aptitud para principiantes 38/100
objectbox/objectbox-java#1198 · 1 comentario ·
Todos los issues de objectbox/objectbox-java
Issues similares
-
Bug Java Platform: Java
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
getsentry/sentry-java#6138 · 1 comentario ·
-
bug needs triage p2
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
GoogleCloudPlatform/DataflowTemplates#4273 · 1 comentario ·
-
[LNG prod] Release 2.4.6 Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
[Studio][Bug] Bulk-deleting a full page of alert rules steps the page back while more rules remain Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
apache/rocketmq-dashboard#4654 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100