scala - Discard values while inserting and updating data using slick -


i using slick play2. have multiple fields in database managed database. don't want create or update them, want them while reading values.

for example, suppose have

case class mappeddummytable(id: int, .. 20 other fields, modified_time: optional[timestamp])

which maps dummy in database. modified_time managed database.

the problem during insert or update, create instance of mappeddummytable without modified time attribute , pass slick create/update like

tablequery[mappeddummytable].insert(instanceofmappeddummytable)

for this, slick creates query

 insert mappeddummytable(id,....,modified_time) values(1,....,null) 

and updates modified_time null, don't want. want slick ignore fields while updating , creating.

for updating, can

tablequery[mappeddummytable].map(fieldstobeupdated).update(values)

but leads 20 odd fields in map method looks ugly.

is there better way?

update:

the best solution found using multiple projection. created 1 projection values , update , insert data

maybe need write triggers in table if don't want write code row => (row.id,...other 20 fields)

or try use none instead of null?


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -