What is the difference between inSet and inSetBind

2020-04-02 03:08发布

问题:

The ScalaDoc of the functions has not been filled out.

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.

回答1:

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.



标签: scala slick