Reputation: 4673
How do you compare MappedTo[T] with raw T columns?
I have a problem (Cannot perform option-mapped operation) with this code:
for {
toEventLink <- Link.linksFromQuery(fromEntity).filter(_.toTable === Event.tableName)
event <- Event.table.filter(e => e.id === toEventLink.toId)
} yield event
In: e.id === toEventLink.toId
where e.id
is an ID (extends MappedTo[Long]) and toEventLink.toId
is a raw Long.
Upvotes: 2
Views: 187
Reputation: 4320
This compiler check is doing what it’s supposed to do (e.g., not let you accidently compare an ID against something that isn’t an ID). But I can totally see why this would be useful (e.g., when migrating a schema to start to used typed keys).
You can use asColumnOf
to cast a column to the type you want. For example:
e => e.id.asColumnOf[Long] === toEventLink.toId
There is a an issue open to make a more general solution for this: https://github.com/slick/slick/issues/1664
Upvotes: 4