Spot filter or where logical operations are no longer supported?

I use slick 2.0.2, and I just want to make a simple filter or use a helper operator, I just want to do logical operations like "and", "or" and "not" inside the filter:

val subjectdata = TableQuery[SubjectTable]
...
subjectdata.where(i=>(i.id===id && i.userId===rs.user.get.identityId.userId)).list()

and get the error:

[error] G:\testprojects\slickplay\app\controllers\ShopController.scala:89: Cannot perform option-mapped operation
[error]       with type: (Long, String) => R
[error]   for base type: (Long, Long) => Boolean
[error]     subjectdata.where(i=>(i.id===id && i.userId===rs.user.get.identityId
.userId)).list()
[error]
                           ^

In slick 1.0.1, I can do:

val results = Query(TableClass)
.filter(r => r.isNull || r.expires > new Timestamp(DateTime.now().getMillis()))
.list

I want to do something like this in TableQuery in Slick2. How to do it?

+4
source share
1 answer

, Slick , Scala. , . Double-Double Option [Double] , Int .

[error] G:\testprojects\slickplay\app\controllers\ShopController.scala:89: Cannot perform option-mapped operation
[error]       with type: (Long, String) => R
[error]   for base type: (Long, Long) => Boolean
[error]     subjectdata.where(i=>(i.id===id && i.userId===rs.user.get.identityId
.userId)).list()

(Long, String) => R , . , id, rs.user.get.identityId . Int .toInt. db- .asColumnOf[String].

+8

Source: https://habr.com/ru/post/1542086/


All Articles