Skip to content

Instantly share code, notes, and snippets.

Mesut mesut

Block or report user

Report or block mesut

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mesut
mesut / jdbcarray.scala
Created Feb 13, 2020
scalikejdbc custom array types
View jdbcarray.scala
implicit def sqlArrayToIntListBinder: Binders[List[Int]] = {
def sqlArrayToIntList(a: java.sql.Array): List[Int] = a.getArray.asInstanceOf[Array[AnyRef]].map(_.asInstanceOf[Int]).toList
Binders[List[Int]]((r, i) => sqlArrayToIntList(r.getArray(i)))((r, s) => sqlArrayToIntList(r.getArray(s)))(list => (s, i) => {
val array = s.getConnection.createArrayOf("integer", list.map(_.asInstanceOf[AnyRef]).toArray)
s.setArray(i, array)
})
}
implicit def sqlArrayToStringListBinder: Binders[List[String]] = {
You can’t perform that action at this time.