Mike
Mike

Reputation: 797

What is the difference between inSet and inSetBind in Slick

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.

Upvotes: 25

Views: 11852

Answers (1)

virtualeyes
virtualeyes

Reputation: 11245

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.

Upvotes: 24

Related Questions