Slick中的inSet和inSetBind有什么区别 [英] What is the difference between inSet and inSetBind in Slick

查看:40
本文介绍了Slick中的inSet和inSetBind有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

函数的ScalaDoc 尚未填写.

我知道这些方法用于模仿 SQL 的 IN 关键字(例如,可以执行 SELECT * FROM table WHERE id IN VALUES(1, 42, 101)table.filter(_.id inSet Seq(1, 42, 101))).我不知道这个绑定"版本是什么,也不知道我应该使用哪个版本.

I know that the methods are used for mimicking SQL's IN keyword (eg, SELECT * FROM table WHERE id IN VALUES(1, 42, 101) could be done with table.filter(_.id inSet Seq(1, 42, 101))). I don't know what this "bind" version is or how to choose which I should be using.

推荐答案

inSetinSetBind 的不安全版本,它根据传入的值生成安全/转义的 sql 值输入.在您手动设置值的示例中,两种类型的绑定同样安全.

inSet is an unsafe version of inSetBind which generates a safe/escaped sql value based on passed in input. In your example where the value is manually set, the two types of bind are equally safe.

通常使用绑定参数可以获得性能提升(通过生成的准备好的语句),但不是集合值的情况.请参阅此处了解详情.

Normally with bound parameters you get a performance boost (via generated prepared statement), but not the case with collection values. See here for the details.

这篇关于Slick中的inSet和inSetBind有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆