Unable to apply Aggregation (max) on DateTime column
lakshmankollipara opened this issue · 2 comments
object MyTable extends BasicTable[MyClass]("my_table") { def id= column[String]("UserId") def updated= column[LocalDateTime]("Updated") def * = userId ~ actionDate ~ description <> (MyCLass, MyClass.unapply _) }
Given above DAO, I am trying to groupBy based on id and aggregate (max) on updated field.
SELECT id, max(updated) FROM my_table;
val q = TableQuery[MyTable] db.run(q.groupBy(_.id).map { case (id, e) => id -> e.map(_.updated).max }
The above snippet throws following error:
value max is not a member of slick.lifted.Query[slick.lifted.Rep[java. time.LocalDateTime],java.time.LocalDateTime,Seq]
@lakshmankollipara I added a test case 864bf0a8 in brach issue-480
.
It seems ok. pls double check!
Thanks @tminglei
It works.
I have an implicit in the same file which prevented it:
implicit val dateTimeMapping: BaseColumnType[LocalDateTime] = MappedColumnType.base[LocalDateTime, Timestamp]( dateTime => Timestamp.valueOf(dateTime), timeStamp => timeStamp.toLocalDateTime )
I was using this implicit conversion to filter LocalDateTime(<=, >=).
If I remove this implicit from the file, it works fine.