4

I get a query from gitlab ci and I want to execute it.

If I hardcode the query is the sql"""""" syntax it works. But I want to pass it as a variable(the whole query). the SqlInterperator doesn't take the value of the variable and hence returns an empty fragment.

 val q2 = sql"""$query"""
  println(q2) // Fragment("?")

  test("hive ViewTest") {
    q2
      .update
      .run
      .transact(xa)
      .unsafeRunSync() shouldEqual(0)
  }

just info I have these as imports

import scala.concurrent.ExecutionContext
import cats.effect.{ContextShift, IO}
import doobie.free.connection.{close, unit}
import doobie.implicits._
import doobie.util.transactor.{Strategy, Transactor}
import org.scalatest.{BeforeAndAfterAllConfigMap, ConfigMap, FunSuite, Matchers}

Is it possible?

Krzysztof Atłasik
  • 21,985
  • 6
  • 54
  • 76
Sam
  • 497
  • 1
  • 10
  • 34

1 Answers1

1

Figured it out! You can use the Fragment.const api

e.g.

Fragment.const(query)
Sam
  • 497
  • 1
  • 10
  • 34