Slick 3: insertOrUpdate not working Slick 3: insertOrUpdate not working postgresql postgresql

Slick 3: insertOrUpdate not working


insertOrUpdate is only supported in MySQL driver

http://slick.lightbend.com/doc/3.2.1/supported-databases.html

You can try this library which gives you the implementation of insertOrUpdate/upsert

https://github.com/tminglei/slick-pg

This is how we use it on current project.

import com.github.tminglei.slickpg._import com.typesafe.config.ConfigFactoryimport slick.basic.Capabilityobject DBComponent {  private val config = ConfigFactory.load()  val driver = config.getString("rdbms.properties.driver") match {    case "org.h2.Driver" => slick.jdbc.H2Profile    case _               => MyPostgresProfile  }  import driver.api._  val db: Database = Database.forConfig("rdbms.properties")}trait MyPostgresProfile extends ExPostgresProfile {  // Add back `capabilities.insertOrUpdate` to enable native `upsert` support; for postgres 9.5+  override protected def computeCapabilities: Set[Capability] =    super.computeCapabilities + slick.jdbc.JdbcCapabilities.insertOrUpdate  override val api: MyAPI.type = MyAPI  object MyAPI extends API}object MyPostgresProfile extends MyPostgresProfile