I am using slick with play2. I have several fields in a database that are managed by a database. I do not want to create or update them, but I want to get them by reading the values.
For example, suppose that
case class MappedDummyTable(id: Int, .. 20 other fields, modified_time: Optional[Timestamp])
which displays the Dummy in the database. modified_time is database driven.
The problem is during insert or update , I create an instance of MappedDummyTable without the changed time attribute and pass it to slick to create / update, for example
TableQuery[MappedDummyTable].insert(instanceOfMappedDummyTable)
To do this, Slick creates a request as
Insert INTO MappedDummyTable(id,....,modified_time) Values(1,....,null)
and updates modified_time as NULL, which I don't want. I want Slick to ignore fields when updating and creating.
For the update I can do
TableQuery[MappedDummyTable].map(fieldsToBeUpdated).update(values)
but this leads to 20 odd fields in the map method, which looks ugly.
Is there a better way?
Update:
The best solution I found was to use multiple projections. I created one forecast to get the values, and the other to update and insert the data.