Skip to content

Commit 987c6db

Browse files
added array sql type
1 parent fc31beb commit 987c6db

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

ktorm-core/src/main/kotlin/org/ktorm/schema/SqlTypes.kt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package org.ktorm.schema
1818

1919
import java.math.BigDecimal
2020
import java.sql.*
21+
import java.sql.Array
2122
import java.sql.Date
2223
import java.time.*
2324
import java.time.format.DateTimeFormatterBuilder
@@ -557,3 +558,24 @@ public object UuidSqlType : SqlType<UUID>(Types.OTHER, "uuid") {
557558
return rs.getObject(index) as UUID?
558559
}
559560
}
561+
562+
/**
563+
* Define a column typed of [UuidSqlType].
564+
*/
565+
public fun BaseTable<*>.array(name: String): Column<Array> {
566+
return registerColumn(name, ArraySqlType)
567+
}
568+
569+
/**
570+
* [SqlType] implementation represents `array` SQL type.
571+
*/
572+
public object ArraySqlType : SqlType<Array>(Types.OTHER, "array") {
573+
574+
override fun doSetParameter(ps: PreparedStatement, index: Int, parameter: Array) {
575+
ps.setObject(index, parameter)
576+
}
577+
578+
override fun doGetResult(rs: ResultSet, index: Int): Array? {
579+
return rs.getObject(index) as Array?
580+
}
581+
}

0 commit comments

Comments
 (0)