Let's consider this table:
+----------+----------+
| user_id | store_id |
+----------+----------+
| 39 | 8 |
| 8 | 39 |
| 5 | 11 |
+----------+----------+
I mapped it with slick with (dropping indexes & foreign keys for simplifying it):
case class FavoriteStore(userId: Long, storeId: Long)
class FavoriteStoreTable(tag: Tag)
extends Table[FavoriteStore](tag, "FAVORITE_STORE") {
def userId = column[Long]("USER_ID")
def storeId = column[Long]("STORE_ID")
override def * = (userId, storeId) <>
(FavoriteStore.tupled, FavoriteStore.unapply)
}
I would like to be able to write the following SQL query with Slick:
INSERT INTO favorite_store (user_id, store_id) VALUES (39, 8)
WHERE NOT EXISTS
(SELECT * FROM favorite_store WHERE user_id = 39 AND store_id = 8)
Any idea?