diff --git a/src/main/kotlin/com/geekbeast/postgres/PostgresArrays.kt b/src/main/kotlin/com/geekbeast/postgres/PostgresArrays.kt index b6100933..96428405 100644 --- a/src/main/kotlin/com/geekbeast/postgres/PostgresArrays.kt +++ b/src/main/kotlin/com/geekbeast/postgres/PostgresArrays.kt @@ -24,7 +24,9 @@ import java.sql.SQLException import java.util.UUID import com.geekbeast.postgres.PostgresDatatype import java.sql.Connection +import java.sql.Date import java.sql.ResultSet +import java.time.LocalDate import java.util.stream.Stream /** @@ -120,6 +122,24 @@ object PostgresArrays { return connection.createArrayOf(PostgresDatatype.SMALLINT.sql(), values.toTypedArray()) } + @JvmStatic + @Throws(SQLException::class) + fun createDateArray(connection: Connection, values: Stream): java.sql.Array { + return connection.createArrayOf(PostgresDatatype.DATE.sql(), values.toArray()) + } + + @JvmStatic + @Throws(SQLException::class) + fun createDateArray(connection: Connection, vararg value: LocalDate): java.sql.Array { + return connection.createArrayOf(PostgresDatatype.DATE.sql(), value) + } + + @JvmStatic + @Throws(SQLException::class) + fun createDateArray(connection: Connection, values: Collection): java.sql.Array { + return connection.createArrayOf(PostgresDatatype.DATE.sql(), values.toTypedArray()) + } + @JvmStatic @Throws(SQLException::class) fun getTextArray(rs: ResultSet, column: String): Array { @@ -144,6 +164,12 @@ object PostgresArrays { return rs.getArray(column).array as Array> } + @JvmStatic + @Throws(SQLException::class) + fun getDateArray(rs: ResultSet, column: String): List { + return (rs.getArray(column).array as Array).map { it.toLocalDate() } + } + @JvmStatic @Throws(SQLException::class) fun getUuidArray(rs: ResultSet, column: String): Array? {