Skip to content

Commit ba4ff02

Browse files
authored
Merge pull request #113 from touchlab/conradev-empty-blobs
Conradev empty blobs
2 parents 4deea8d + e8c81b5 commit ba4ff02

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

sqliter-driver/src/nativeCommonTest/kotlin/co/touchlab/sqliter/NativeStatementTest.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,31 +218,33 @@ class NativeStatementTest : BaseDatabaseTest(){
218218
}
219219
}
220220

221-
val TWO_COL_WITH_BLOB = "CREATE TABLE test (num INTEGER NOT NULL, " +
222-
"blb BLOB NOT NULL)"
221+
val THREE_COL_WITH_BLOB = "CREATE TABLE test (num INTEGER NOT NULL, " +
222+
"blb BLOB NOT NULL, null_blb BLOB)"
223223

224224
@Test
225225
fun bindEmptyBlob() {
226-
basicTestDb(TWO_COL_WITH_BLOB) {
226+
basicTestDb(THREE_COL_WITH_BLOB) {
227227
it.withConnection {
228-
it.withStatement("insert into test(num, blb)values(?,?)") {
228+
it.withStatement("insert into test(num, blb, null_blb)values(?,?,?)") {
229229
bindLong(1, 22)
230-
bindBlob(2, ByteArray(0){it.toByte()})
230+
bindBlob(2, byteArrayOf())
231+
bindBlob(3, null)
231232
executeInsert()
232233
}
233234

234-
it.withStatement("select blb from test") {
235+
it.withStatement("select blb, null_blb from test") {
235236
val query = query()
236237
query.next()
237238
assertEquals(query.getBytes(query.columnNames["blb"]!!).size, 0)
239+
assertEquals(query.getBytesOrNull(query.columnNames["null_blb"]!!), null)
238240
}
239241
}
240242
}
241243
}
242244

243245
@Test
244246
fun bindBlob() {
245-
basicTestDb(TWO_COL_WITH_BLOB) {
247+
basicTestDb(THREE_COL_WITH_BLOB) {
246248
it.withConnection {
247249
it.withTransaction {
248250
it.withStatement("insert into test(num, blb)values(?,?)") {

0 commit comments

Comments
 (0)