Skip to content

Commit

Permalink
Merge pull request #231 from JetBrains/graph-store-XD-1169-fixed
Browse files Browse the repository at this point in the history
#XD-1169 fixed
  • Loading branch information
leostryuk authored Dec 17, 2024
2 parents 5d77a6b + d66c963 commit 93cb3c4
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.orientechnologies.common.concur.lock.OModificationOperationProhibited
import com.orientechnologies.orient.core.db.ODatabaseSession
import com.orientechnologies.orient.core.db.ODatabaseSessionInternal
import com.orientechnologies.orient.core.exception.ORecordNotFoundException
import com.orientechnologies.orient.core.id.OEmptyRecordId
import com.orientechnologies.orient.core.metadata.schema.OClass
import com.orientechnologies.orient.core.metadata.sequence.OSequence
import com.orientechnologies.orient.core.record.ORecord
Expand Down Expand Up @@ -444,7 +445,12 @@ class OStoreTransactionImpl(
override fun toEntityId(representation: String): EntityId {
requireActiveTransaction()
val legacyId = PersistentEntityId.toEntityId(representation)
return store.requireOEntityId(legacyId)
val oEntityId = store.requireOEntityId(legacyId)
return if (oEntityId == ORIDEntityId.EMPTY_ID) {
ORIDEntityId(legacyId.typeId, legacyId.localId, OEmptyRecordId(), null)
} else {
oEntityId
}
}

override fun getSequence(sequenceName: String): Sequence {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package jetbrains.exodus.entitystore.orientdb

import com.orientechnologies.orient.core.id.OEmptyRecordId
import com.orientechnologies.orient.core.metadata.schema.OClass
import com.orientechnologies.orient.core.metadata.schema.OType
import com.orientechnologies.orient.core.storage.ORecordDuplicatedException
Expand Down Expand Up @@ -193,6 +194,41 @@ class OPersistentStoreTest: OTestMixin {
}
}

@Test
fun `toEntityId(presentation) from not existent idString will return OEntityId with correct xodus part and empty orient`() {
val issueId = orientDb.createIssue("trista").id
val notExistingEntityId = PersistentEntityId(300, 301)
val partiallyExistingEntityId1 = PersistentEntityId(issueId.typeId, 301)
val partiallyExistingEntityId2 = PersistentEntityId(300, issueId.localId)
val totallyExistingEntityId = PersistentEntityId(issueId.typeId, issueId.localId)
val empty = OEmptyRecordId()
orientDb.store.executeInTransaction { txn->
with(txn.toEntityId(notExistingEntityId.toString()) as OEntityId){
assertEquals(notExistingEntityId.localId, localId)
assertEquals(notExistingEntityId.typeId, typeId)
assertEquals(empty.clusterId, asOId().clusterId)
assertEquals(empty.clusterPosition, asOId().clusterPosition)
}
with(txn.toEntityId(partiallyExistingEntityId1.toString()) as OEntityId){
assertEquals(partiallyExistingEntityId1.localId, localId)
assertEquals(partiallyExistingEntityId1.typeId, typeId)
assertEquals(empty.clusterId, asOId().clusterId)
assertEquals(empty.clusterPosition, asOId().clusterPosition)
}
with(txn.toEntityId(partiallyExistingEntityId2.toString()) as OEntityId){
assertEquals(partiallyExistingEntityId2.localId, localId)
assertEquals(partiallyExistingEntityId2.typeId, typeId)
assertEquals(empty.clusterId, asOId().clusterId)
assertEquals(empty.clusterPosition, asOId().clusterPosition)
}
with(txn.toEntityId(totallyExistingEntityId.toString()) as OEntityId){
assertEquals(totallyExistingEntityId.localId, localId)
assertEquals(totallyExistingEntityId.typeId, typeId)
assertEquals(issueId.asOId(), asOId())
}
}
}

@Test
fun `propertyNames does not count internal properties`() {
val issue = orientDb.store.computeInTransaction { txn ->
Expand Down

0 comments on commit 93cb3c4

Please sign in to comment.