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

feat: Add support for variable-length binary columns in H2 #2100

Merged
merged 2 commits into from
May 28, 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 @@ -741,7 +741,8 @@ open class Table(name: String = "") : ColumnSet(), DdlAware {
/**
* Creates a binary column, with the specified [name], for storing byte arrays of arbitrary size.
*
* **Note:** This function is only supported by Oracle and PostgeSQL dialects, for the rest please specify a length.
* **Note:** This function is only supported by Oracle, PostgeSQL, and H2 dialects. For the rest, please specify a length.
* For H2 dialects, the maximum size is 1,000,000,000 bytes.
*
* @sample org.jetbrains.exposed.sql.tests.shared.DDLTests.testBinaryWithoutLength
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ import java.sql.DatabaseMetaData
import java.util.*

internal object H2DataTypeProvider : DataTypeProvider() {
override fun binaryType(): String {
exposedLogger.error("The length of the Binary column is missing.")
error("The length of the Binary column is missing.")
}
override fun binaryType(): String = "VARBINARY"

override fun uuidType(): String = "UUID"
override fun uuidToDB(value: UUID): Any = value.toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ class DDLTests : DatabaseTestsBase() {

fun SizedIterable<ResultRow>.readAsString() = map { String(it[tableWithBinary.binaryColumn]) }

withDb(listOf(TestDB.POSTGRESQL, TestDB.POSTGRESQLNG, TestDB.SQLITE, TestDB.H2_PSQL)) {
withDb(listOf(TestDB.POSTGRESQL, TestDB.POSTGRESQLNG, TestDB.SQLITE, TestDB.H2_PSQL, TestDB.H2)) {
val exposedBytes = "Exposed".toByteArray()
val kotlinBytes = "Kotlin".toByteArray()

Expand Down
Loading