File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
commonMain/kotlin/org/modelix/model/persistent Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ data class CPTree(
68
68
usesRoleIds -> INT64_WITH_ROLE_IDS
69
69
else -> INT64_WITH_ROLE_NAMES
70
70
}
71
- return " $id /$pv /${getTreeReference().getHash()} / ${if (usesRoleIds) " i" else " n " } "
71
+ return " $id /$pv /${getTreeReference().getHash()}${if (usesRoleIds) " / i" else " " } "
72
72
}
73
73
74
74
override fun getDeserializer (): IObjectDeserializer <CPTree > = DESERIALIZER
@@ -133,7 +133,12 @@ data class CPTree(
133
133
val graph = referenceFactory as IObjectGraph
134
134
return when (persistenceVersion) {
135
135
STRING_IDS -> {
136
- val usesRoleIds = parts.getOrNull(3 ) != " n"
136
+ val usesRoleIds = when (val part = parts.getOrNull(3 )) {
137
+ null -> false
138
+ " n" -> false
139
+ " i" -> true
140
+ else -> throw IllegalArgumentException (" Unknown value `$part ` in $input " )
141
+ }
137
142
CPTree (
138
143
id = treeId,
139
144
int64Hamt = null ,
Original file line number Diff line number Diff line change
1
+ import org.modelix.datastructures.objects.IObjectGraph
1
2
import org.modelix.model.IKeyValueStore
2
3
import org.modelix.model.api.IBranch
3
4
import org.modelix.model.api.IConcept
@@ -11,6 +12,7 @@ import org.modelix.model.lazy.CLVersion
11
12
import org.modelix.model.lazy.createObjectStoreCache
12
13
import org.modelix.model.operations.LegacyBranchAsMutableModelTree
13
14
import org.modelix.model.operations.OTBranch
15
+ import org.modelix.model.persistent.CPTree
14
16
import org.modelix.model.persistent.MapBaseStore
15
17
import kotlin.test.Test
16
18
import kotlin.test.assertEquals
@@ -314,6 +316,13 @@ class TreeSerializationTest {
314
316
assertStore(mapStore)
315
317
}
316
318
319
+ @Test
320
+ fun backwards_compatibility_of_persistence_version_2 () {
321
+ val serialized = " 4f7aa052-43e0-4f5e-b5c8-f197a80507a0/2/V_4I6*Hbk19Lb1sBNIU1k7aA9kGXTI3zBQqYZ9CZje74"
322
+ val deserialized = CPTree .deserialize(serialized, IObjectGraph .FREE_FLOATING )
323
+ assertEquals(serialized, deserialized.serialize())
324
+ }
325
+
317
326
fun assertStore (store : IKeyValueStore ) {
318
327
val deserializedVersion = CLVersion .loadFromHash(store[" branch_master" ]!! , createObjectStoreCache(store))
319
328
val deserializedTree = deserializedVersion.tree
You can’t perform that action at this time.
0 commit comments