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?
Figured it out!
You can use the Fragment.const
api
e.g.
Fragment.const(query)