Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#XD-1169 fixed #231

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading