Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala 如何使用ScalikeJDBC';s使用where子句返回()_Scala_Scalikejdbc - Fatal编程技术网

Scala 如何使用ScalikeJDBC';s使用where子句返回()

Scala 如何使用ScalikeJDBC';s使用where子句返回(),scala,scalikejdbc,Scala,Scalikejdbc,我正在尝试将Postgres的返回与ScalikeJDBC一起使用(请参阅) 假设这对where子句起作用。返回(…)是更新sqlbuilder的成员,而其中返回条件sqlbuilder 更新(Post) .set(sqls“${p.views}=${p.views}+${newViews}”) .式中,等式(p.id,id) .returning(p.id,p.lastUpdated,p.views)//不起作用,因为它不是ConditionSQLBuilder的成员 正如您所说,返回的不是条

我正在尝试将Postgres的返回与ScalikeJDBC一起使用(请参阅)

假设这对
where
子句起作用。
返回(…)
更新sqlbuilder
的成员,而
其中
返回
条件sqlbuilder

更新(Post)
.set(sqls“${p.views}=${p.views}+${newViews}”)
.式中,等式(p.id,id)
.returning(p.id,p.lastUpdated,p.views)//不起作用,因为它不是ConditionSQLBuilder的成员

正如您所说,
返回的
不是
条件SQLBuilder的成员。但是,您可以在
where
子句之后使用
append
方法,因为它是在
ConditionSQLBuilder
上定义的:

update(Post)
   .set(sqls"${p.views} = ${p.views} + ${newViews}")
   .where.eq(p.id, id)
   .append(sqls"returning ${p.id}, ${p.lastUpdated}, ${p.views}"
并且,如果要使用生成器将返回列映射到对象中,如下所示:

val postOpt = withSQL(builder).map(Post(p)).single().apply()
然后必须在
SQLSyntax
中使用
${p.result.columnName}
而不是
${p.columnName}
,将其作为参数传递给
append
方法。要映射所有列,只需使用
${p.result.*}