2

I'm trying to run in Slick 3.1 a transaction that contains two updates. The second update is plain SQL using Slick's sqlu command. This is my attempt:

  val table = TableQuery[TableDB]
 
  val update1 = table.filter(f => f.name === name).update(rec)
  val update2 = sqlu"UPDATE table2 SET field = 1 WHERE field = 2"
  
  val action = (for {
          _ <- update1
          _ <- update2   // <-- compilation error here
        } yield ()).transactionally
  val future = db.run(action.asTry)
  // ... rest of the code

Slick complains in update2 line with the following messages

Implicit conversion found: ⇒ augmentString(): scala.collection.immutable.StringOps

type mismatch; found : scala.collection.immutable.IndexedSeq[Unit] required: slick.dbio.DBIOAction[?,?,?]

Is it possible to make this work in a single database transaction?

Community
  • 1
  • 1
ps0604
  • 1,227
  • 23
  • 133
  • 330
  • You sure about that? I just pasted it to my Slick sample project and it's not only compiling but even running fine (though obviously failing on SQL error as I don't have `table2`). Maybe something wrong with imports? Where does `sqlu` points to? It should point you to: `def sqlu(param: Any*): SqlAction[Int, NoStream, Effect] = macro sqluImpl` – Paul Dolega Feb 21 '17 at 09:04
  • Thanks, the problem was that Eclipse complained until I did a Rebuild All. – ps0604 Feb 21 '17 at 13:21

0 Answers0