Skip to content

Commit d68f481

Browse files
authored
Fix hex binary type (#10)
Co-authored-by: hfhbd <[email protected]>
1 parent 359a939 commit d68f481

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/commonMain/kotlin/app/softwork/sqldelight/postgresdriver/PostgresNativeDriver.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ class PostgresCursor(
215215
private inline fun Int.fromHex(): Int = if (this in 48..57) {
216216
this - 48
217217
} else {
218-
this - 97
218+
this - 87
219219
}
220220

221221
// because "normal" CPointer<ByteVar>.toByteArray() functions does not support hex (2 Bytes) bytes
@@ -262,8 +262,8 @@ class PostgresPreparedStatement(private val parameters: Int) : SqlPreparedStatem
262262
}
263263

264264
private sealed interface Data {
265-
inline class Bytes(val bytes: ByteArray) : Data
266-
inline class Text(val text: String) : Data
265+
value class Bytes(val bytes: ByteArray) : Data
266+
value class Text(val text: String) : Data
267267
}
268268

269269
private val _values = arrayOfNulls<Data>(parameters)

src/commonTest/kotlin/app/softwork/sqldelight/postgresdriver/PostgresNativeDriverTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class PostgresNativeDriverTest {
2626

2727
bindLong(3, 6)
2828
bindString(4, "bar 1")
29-
bindBytes(5, null)
29+
bindBytes(5, byteArrayOf(16.toByte(), 12.toByte()))
3030
}
3131
assertEquals(2, result)
3232
val notPrepared = driver.executeQuery(null, "SELECT * from baz limit 1;", parameters = 0, mapper = {
@@ -60,7 +60,7 @@ class PostgresNativeDriverTest {
6060
Simple(it, null, null)
6161
} + listOf(
6262
Simple(5, "bar 0", byteArrayOf(1.toByte(), 2.toByte())),
63-
Simple(6, "bar 1", null),
63+
Simple(6, "bar 1", byteArrayOf(16.toByte(), 12.toByte())),
6464
),
6565
preparedStatement
6666
)

0 commit comments

Comments
 (0)