aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/core/database/PatchedHsqldbProfile.scala
blob: e2efd321e21d2b405852380d8fc80ec3ff8efc4d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package xyz.driver.core.database

import slick.jdbc.{HsqldbProfile, JdbcType}
import slick.ast.FieldSymbol
import slick.relational.RelationalProfile

trait PatchedHsqldbProfile extends HsqldbProfile {
  override def defaultSqlTypeName(tmd: JdbcType[_], sym: Option[FieldSymbol]): String = tmd.sqlType match {
    case java.sql.Types.VARCHAR =>
      val size = sym.flatMap(_.findColumnOption[RelationalProfile.ColumnOption.Length])
      size.fold("LONGVARCHAR")(l => if (l.varying) s"VARCHAR(${l.length})" else s"CHAR(${l.length})")
    case _ => super.defaultSqlTypeName(tmd, sym)
  }
}

object PatchedHsqldbProfile extends PatchedHsqldbProfile