可以产生类似的东西
UPDATE employees SET gender = 'Male' WHERE id IN ('asfd','bleh');
和奎尔?我在文档中找不到和示例,批量更新似乎是另一回事。
它对我有用(试 https://scastie.scala-lang.org/(:
静态查询:
import io.getquill._
val ctx = new SqlMirrorContext(PostgresDialect, SnakeCase)
import ctx._
case class Product(name: String, price: Int)
def products(names: Seq[String], name: String) =
ctx.run {
ctx
.query[Product]
.filter(person => quote(liftQuery(names).contains(person.name)))
.update(_.name -> lift(name))
}
val m = products(Seq("AA", "BB"), "EE")
println(m.string)
动态查询
import io.getquill._
val ctx = new SqlMirrorContext(PostgresDialect, SnakeCase)
import ctx._
case class Product(name: String, price: Int)
def products(names: Seq[String], name: String) =
ctx.run {
ctx
.dynamicQuery[Product]
.filter(person => quote(liftQuery(names).contains(person.name)))
.update(setValue(_.name, name))
}
val m = products(Seq("AA", "BB"), "EE")
println(m.string)
输出:
UPDATE product SET name = ? WHERE name IN (?, ?)