Skip to content

Commit

Permalink
fix: EXPOSED-339 Oracle alias for blob does not work (#2048)
Browse files Browse the repository at this point in the history
* fix: EXPOSED-339 Oracle alias for blob does not work

* fix: EXPOSED-339 revert changes in ResultRow, move fix to ColumnType
  • Loading branch information
obabichevjb committed Apr 17, 2024
1 parent 8146b78 commit 713ad95
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ class BlobColumnType(
is ExposedBlob -> value
is InputStream -> ExposedBlob(value)
is ByteArray -> ExposedBlob(value)
is Blob -> ExposedBlob(value.binaryStream)
else -> error("Unexpected value of type Blob: $value of ${value::class.qualifiedName}")
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.jetbrains.exposed.sql.tests.shared.types

import junit.framework.TestCase.assertEquals
import org.jetbrains.exposed.dao.id.IntIdTable
import org.jetbrains.exposed.sql.alias
import org.jetbrains.exposed.sql.insert
import org.jetbrains.exposed.sql.statements.api.ExposedBlob
import org.jetbrains.exposed.sql.tests.DatabaseTestsBase
import org.junit.Test
import java.nio.charset.Charset

class BlobColumnTypeTests : DatabaseTestsBase() {
object BlobTable : IntIdTable("test-blob") {
val content = blob("content")
}

@Test
fun testWriteAndReadBlobValueViaAlias() {
withTables(BlobTable) {
val sampleData = "test-sample-data"
BlobTable.insert {
it[content] = ExposedBlob(sampleData.toByteArray())
}

val alias = BlobTable.content.alias("content_column")
val content = BlobTable.select(alias).single()[alias].bytes.toString(Charset.defaultCharset())
assertEquals(content, sampleData)
}
}
}

0 comments on commit 713ad95

Please sign in to comment.