我正在尝试在过滤器中使用日期时间的 Column[DateTime],但只是无法弄清楚如何使其工作。
import play.api.Play.current
import play.api.db.slick.Config.driver.simple._
import play.api.db.slick._
import org.joda.time.{DateTime, DateTimeComparator, DateTimeZone}
private val dateComparator = DateTimeComparator.getInstance()
implicit def dateTimeToScalaWrapper(dt: DateTime): DateTimeWrapper = new DateTimeWrapper(dt)
class DateTimeWrapper(dt: DateTime) extends Ordered[DateTime] with Ordering[DateTime] {
def compare(that: DateTime): Int = dateComparator.compare(dt, that)
def compare(a: DateTime, b: DateTime): Int = dateComparator.compare(a, b)
}
implicit def jodaType = MappedColumnType.base[DateTime, Timestamp](
{d => new Timestamp(d.getMillis)} ,
{d => new DateTime(d.getTime, UTC)}
)
def removeTimeSlots(start: DateTime, end: DateTime, reservationId: Long) : Int = DB withTransaction { implicit session =>
timeSlots.filter(x => x.reservationId == reservationId && x.startTime >= start && x.starTime <= end).delete
}
在我比较 x.startTime 并开始时,我收到以下错误:
Error:(90, -1) Play 2 Compiler:
Reservations.scala:90: polymorphic expression cannot be instantiated to expected type;
found : [R]scala.slick.lifted.Column[R]
required: Boolean
我有机会在我的代码中进行这些比较吗?