Where in the Slick 3 documentation is it documented on how to do an insertOrUpdate
-like operation?
insertOrUpdate with Slick 3
You mean something like this code? (From this answer.) BTW: asking for external resources is off-topic on SO. –
Heartwhole
@GáborBakos It'd be nice to have that documented in slick.typesafe.com/doc/3.0.0. Surprised there appears to be nothing about insertOrUpdate. Thanks for the BTW. :) If you don't mind, where can I read about this rule? I'd like to become a better SO citizen. :) –
Terriss
I think you can submit an issue to their tracker, probably referencing issue 6 to fix the missing documentation problem (unless you find an issue with that topic). The off-site resource thing is on stackoverflow.com/help/on-topic, point 4. –
Heartwhole
Question is valid, just reformulate it as "how to do insertOrUpdate in Slick 3?" –
Nayarit
The insertOrUpdate method that comes with slick 3.x is limited to MySQL Only. You won't get any warnings/code documentation, it will just throw Integrity exceptions.
In order to upsert with Slick if using Postgres, you can use slick-pg.
This support is there in Slick . Look at this merge : Pull Request Merged Here The support was added in Slick 2.1 .
These are also called upsert
statements.
However i would think you would want to use plain SQL(for the native DB you are using) for this kind of requirement. Look here for examples of how to use Slick to do this.
Basically code that looks like the following ,
val reviews = TableQuery[<Class extending Table>]
val upsert: DBIO[Int] = reviews.insertOrUpdate(<value to be inserted>)
SimpleInsertActionComposer
contains method required: doc link
© 2022 - 2024 — McMap. All rights reserved.