does not compile

throws and error on the last line: "value mapN is not a member of (doobie.Update0, doobie.Update0)
mail@pastecode.io avatar
unknown
scala
2 years ago
1.2 kB
4
Indexable
Never
package repository

import org.scalatest.flatspec.AnyFlatSpec
import cats._
import cats.data._
import cats.effect._
import cats.implicits._
import cats.syntax.apply._
import doobie._
import doobie.implicits._
import doobie.h2._
import doobie.util.ExecutionContexts

class H2Spec extends AnyFlatSpec {

  "Given H2 connection" should "write and read into the datbase" in {
    val transactor: Resource[IO, H2Transactor[IO]] =
      for {
        ce <- ExecutionContexts.fixedThreadPool[IO](32) // our connect EC
        xa <- H2Transactor.newH2Transactor[IO](
          "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", // connect URL
          "sa",                                   // username
          "",                                     // password
          ce,                                     // await connection here
        )
      } yield xa

    val drop: Update0 =
      sql"""
        DROP TABLE IF EXISTS person
      """.update

    val create: Update0 =
      sql"""
      CREATE TABLE person (
        id   SERIAL,
        name VARCHAR NOT NULL UNIQUE,
        age  SMALLINT
      )
      """.update
    (drop, create).mapN(_ + _).transact(transactor).unsafeRunSync
  }
}