def cond[A](value: A)(f: PartialFunction[A, SQLBuilder => SQLBuilder]): SQLBuilder
こんな感じの(実際にはSQLBuilderはサブクラス型にしないとだけど)あれば下みたいに書けるかなー
val id: Option[Int] = ...
val name: Option[String] = ...
select(c.*)
.from(Customer as c)
.where
.cond(id) { case Some(i) => _.eq(c.id, i) }
.and
.cond(name) { case Some(n) => _.eq(c.name, n) }
と思うけど、 .where とか .and とかはどうしょうもなくてぐぬぬ
あ、 両方とも None だった場合に where が浮く……