Skip to content

Commit

Permalink
fix warning
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentlauvlwj committed Jan 19, 2025
1 parent 9ac1b10 commit e1ad8c6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
22 changes: 12 additions & 10 deletions ktorm-core/src/main/kotlin/org/ktorm/database/CachedRowSet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ import java.math.BigInteger
import java.net.URI
import java.net.URL
import java.sql.*
import java.sql.Array as SQLArray
import java.sql.Date
import java.sql.ResultSet.*
import java.time.*
import java.util.*
import javax.sql.rowset.serial.*
import kotlin.use

/**
* Special implementation of [ResultSet], used to hold the query results for Ktorm.
Expand Down Expand Up @@ -245,7 +247,7 @@ public open class CachedRowSet(rs: ResultSet) : ResultSet {
is SQLData -> SerialStruct(obj, _typeMap)
is Blob -> try { MemoryBlob(obj) } finally { obj.free() }
is Clob -> try { MemoryClob(obj) } finally { obj.free() }
is java.sql.Array -> try { MemoryArray(obj, _typeMap) } finally { obj.free() }
is SQLArray -> try { MemoryArray(obj, _typeMap) } finally { obj.free() }
else -> obj
}
}
Expand Down Expand Up @@ -276,9 +278,9 @@ public open class CachedRowSet(rs: ResultSet) : ResultSet {
}

private class MemoryArray(
array: java.sql.Array,
array: SQLArray,
typeMap: Map<String, Class<*>>?
) : java.sql.Array by if (typeMap != null) SerialArray(array, typeMap) else SerialArray(array) {
) : SQLArray by if (typeMap != null) SerialArray(array, typeMap) else SerialArray(array) {

override fun free() {
// no-op
Expand Down Expand Up @@ -396,7 +398,7 @@ public open class CachedRowSet(rs: ResultSet) : ResultSet {
override fun getBytes(columnIndex: Int): ByteArray? {
return when (val value = getColumnValue(columnIndex)) {
null -> null
is ByteArray -> Arrays.copyOf(value, value.size)
is ByteArray -> value.copyOf()
is Blob -> value.binaryStream.use { it.readBytes() }
else -> throw SQLException("Cannot convert ${value.javaClass.name} value to byte[].")
}
Expand Down Expand Up @@ -1076,10 +1078,10 @@ public open class CachedRowSet(rs: ResultSet) : ResultSet {
}
}

override fun getArray(columnIndex: Int): java.sql.Array? {
override fun getArray(columnIndex: Int): SQLArray? {
return when (val value = getColumnValue(columnIndex)) {
null -> null
is java.sql.Array -> value
is SQLArray -> value
else -> throw SQLException("Cannot convert ${value.javaClass.name} value to Array.")
}
}
Expand All @@ -1100,7 +1102,7 @@ public open class CachedRowSet(rs: ResultSet) : ResultSet {
return getClob(findColumn(columnLabel))
}

override fun getArray(columnLabel: String): java.sql.Array? {
override fun getArray(columnLabel: String): SQLArray? {
return getArray(findColumn(columnLabel))
}

Expand Down Expand Up @@ -1195,12 +1197,12 @@ public open class CachedRowSet(rs: ResultSet) : ResultSet {
}

@Deprecated("The result set is not updatable.", level = DeprecationLevel.ERROR)
override fun updateArray(columnIndex: Int, x: java.sql.Array?): Nothing {
override fun updateArray(columnIndex: Int, x: SQLArray?): Nothing {
throw SQLFeatureNotSupportedException("The result set is not updatable.")
}

@Deprecated("The result set is not updatable.", level = DeprecationLevel.ERROR)
override fun updateArray(columnLabel: String?, x: java.sql.Array?): Nothing {
override fun updateArray(columnLabel: String?, x: SQLArray?): Nothing {
throw SQLFeatureNotSupportedException("The result set is not updatable.")
}

Expand Down Expand Up @@ -1460,7 +1462,7 @@ public open class CachedRowSet(rs: ResultSet) : ResultSet {
Instant::class -> getInstant(columnIndex)
Blob::class -> getBlob(columnIndex)
Clob::class -> getClob(columnIndex)
java.sql.Array::class -> getArray(columnIndex)
SQLArray::class -> getArray(columnIndex)
Ref::class -> getRef(columnIndex)
URL::class -> getURL(columnIndex)
else -> getObject(columnIndex)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.ktorm.support.sqlite

import org.junit.Test
import org.ktorm.database.use
import org.ktorm.dsl.*
import org.ktorm.schema.TextSqlType
import java.sql.Clob
Expand Down

0 comments on commit e1ad8c6

Please sign in to comment.