Custom Functions

Suppose your database has a SHA1 function that takes a String and returns a String

You can define :

Then you can use the sha1 function in expressions :

The arguments and return type of your custom function need be one of the following Squeryl types (defined in org.squeryl.dsl) :

Where :

  • A is Int, Long, Float, Double, BigDecimal or Option[Int], Option[Long], etc…
  • B is String or Option[String]
  • C is Date, Timestamp, Option[Date] or Option[Timestamp]
  • D is Boolean or Option[Boolean]

Note: you need 0.9.5-Beta or higher to have the appropriate implicit OutMapper[A] in scope (the implicit def is defined in an ancestor of PrimitiveTypeMode, CustomTypeMode and RecordTypeMode (org.squeryl.dsl.TypeArithmetic))