FunctionNode request sys_extract_utc(systemtimestamp)

24 views
Skip to first unread message

Æthyr

unread,
May 30, 2017, 7:23:22 PM5/30/17
to Squeryl
I have a nullable timestamp field in my table
In the schema it is of type Option[Timestamp]

How would I write a FunctionNode in my EntryPoint to be able to call this in update statements?

Æthyr

unread,
May 30, 2017, 7:27:30 PM5/30/17
to Squeryl
I got as far as:

def SYS_EXTRACT_UTC = new FunctionNode("sys_extract_utc(systemtimestamp)", Nil) with TypedExpression[Timestamp, TTimestamp] {
  lazy val mapper
= timestampTEF.createOutMapper
}

I got stuck trying to make it work with Option.

Æthyr

unread,
Aug 8, 2017, 11:32:52 AM8/8/17
to Squeryl
I eventually solved it with:

def oracleSysTimestampUTC = new ExpressionNode with TypedExpression[Option[Timestamp],TOptionTimestamp] {
    def doWrite(sw: StatementWriter) = {
      sw.write("sys_extract_utc(systimestamp)")
    }

    override def children = Nil

    lazy val mapper: OutMapper[Option[Timestamp]] = optionTimestampTEF.createOutMapper
  }

This allowed me to do things like:
update(schema.foos) (
  foo =>
    where(foo.id in ids)
    set(
      foo.changedUtc := oracleSysTimestampUTC
    )
)



Reply all
Reply to author
Forward
0 new messages