我的问题很简单.
我有一列seqNum: Double是NOT NULL DEFAULT 1在CREATE TABLE声明如下:
CREATE TABLE some_table
(
...
seq_num DECIMAL(18,10) NOT NULL DEFAULT 1,
...
);
Run Code Online (Sandbox Code Playgroud)
用户可以seqNum在UI中输入或不输入值.所以接受PLAY形式如下:
case class SomeCaseClass(..., seqNum: Option[Double], ...)
val secForm = Form(mapping(
...
"seqNum" -> optional(of[Double]),
...
)(SomeCaseClass.apply)(SomeCaseClass.unapply))
Run Code Online (Sandbox Code Playgroud)
光滑的Table Schema&Objects看起来像这样:
case class SomeSection (
...
seqNum: Option[Double],
...
)
class SomeSections(tag: Tag) extends Table[SomeSection](tag, "some_table") {
def * = (
...
seqNum.?,
...
) <> (SomeSection.tupled, SomeSection.unapply _)
...
def seqNum …Run Code Online (Sandbox Code Playgroud)