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

fix: EXPOSED-339 Oracle alias for blob does not work #2048

Merged
merged 2 commits into from
Apr 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 @@ -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)
}
}
}
Loading