We've also seen some issues where our transactions are failing because of fk contraint errors relating to entities created in the transaction. ie.
class Foo(var a: String) extends Entity
class Bar(var b: Foo) extends Entity
transactional {
val a = new Foo("a")
val bs = List(1,2,3).map(_ => new Bar(a))
}
This would fail because it says fk constraint on a
failed. This only seemed to happen immediately after the context started and I have had some difficulty reproducing.
// example use case
case class Foo(a: String, b: Bar)
case class Bar(d: Date)
def find(startDate: Option[Date], endDate: Option[Date]) = {
val query = MaybeFilter(SlickQuery[Foo])
.filter(startDate)(_.b.d >= startDate.get)
.filter(endDate)(_.b.d <= endDate.get)
.query
query.list
}
class Foo(val a: String, val bar: Bar) extends Entity
class Bar(val name: String) extends Entity {
def foos = selec[Foo].where(_.bar :== this)
}
object Status extends Enumeration {
case class Status(name: String) extends Val(name)
val ACTIVE = AccountStatus("active")
val INACTIVE = AccountStatus("inactive")
}
class Foo(name: String, status: Status.Status) extends Entity
SlickQuery[Foo].filter(_.status.col === Status.ACTIVE)
object Status extends Enumeration {
case class Status(name: String) extends Val(name)
val ACTIVE = Status("active")
val INACTIVE = Status("inactive")
}
val a = Status.ACTIVE
val b = Status.Status("active")
val c = a == b // false
val d = a.name == b.name // true