Skip to content

Commit 43aac9a

Browse files
authored
Merge pull request #123 from JetBrains/adopt-orientdb-fix-blobs-in-changes
Fixed class cast in string blobs
2 parents 63e986e + 5a65fa2 commit 43aac9a

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

dnq-transient-store/src/main/kotlin/com/jetbrains/teamsys/dnq/database/ReadonlyTransientEntityImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class ReadonlyTransientEntityImpl(change: TransientEntityChange?, snapshot: OEnt
125125

126126
override fun getBlobString(blobName: String): String? {
127127
return if (changedProperties.containsKey(blobName)) {
128-
changedProperties[blobName] as String?
128+
changedProperties[blobName]?.toString()
129129
} else {
130130
entity.getBlobString(blobName)
131131
}

dnq-transient-store/src/main/kotlin/com/jetbrains/teamsys/dnq/database/TransientEntitiesUpdaterImpl.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,14 @@ class TransientEntitiesUpdaterImpl(
3232
override fun compareTo(other: Any): Int {
3333
return -1
3434
}
35+
36+
override fun toString() = "Empty Binary Data"
3537
}
3638
val NOT_NULL_BLOB = object : Comparable<Any> {
3739
override fun compareTo(other: Any): Int {
3840
return -1
3941
}
42+
override fun toString() = "Binary Data"
4043
}
4144
}
4245

@@ -49,16 +52,20 @@ class TransientEntitiesUpdaterImpl(
4952

5053
override fun setBlob(transientEntity: TransientEntity, blobName: String, stream: InputStream) {
5154
addChangeAndRun {
55+
//this may be implemented another way. by checking if the blob is actually null
56+
val hasBlob = transientEntity.blobNames.contains(blobName)
5257
transientEntity.entity.setBlob(blobName, stream)
53-
transientChangesTracker.propertyChanged(transientEntity, blobName, NOT_NULL_BLOB)
58+
transientChangesTracker.propertyChanged(transientEntity, blobName, if (hasBlob) NOT_NULL_BLOB else NULL_BLOB)
5459
true
5560
}
5661
}
5762

5863
override fun setBlob(transientEntity: TransientEntity, blobName: String, file: File) {
5964
addChangeAndRun {
65+
//this may be implemented another way. by checking if the blob is actually null
66+
val hasBlob = transientEntity.blobNames.contains(blobName)
6067
transientEntity.entity.setBlob(blobName, file)
61-
transientChangesTracker.propertyChanged(transientEntity, blobName, NOT_NULL_BLOB)
68+
transientChangesTracker.propertyChanged(transientEntity, blobName, if (hasBlob) NOT_NULL_BLOB else NULL_BLOB)
6269
true
6370
}
6471
}

0 commit comments

Comments
 (0)