scalikejdbc/scalikejdbc — pull request #244 by seratch (2014-05-06 04:59:26+00:00)
Title: ParameterBinder to enable customizing StatementExecutor#binParams

#### Motivation

@shunjikonishi 's feedback:
https://gist.github.com/shunjikonishi/1eb278c314327af26922

PostgreSQL JDBC driver expects length of binary data when calling `#setBinaryStream`. Currently, ScalikeJDBC users cannot pass extra values when binding params to PreparedStatement.

#### Solution

Just using `ParameterBinder` instead of raw value.

```scala
val bytes = Array[Byte](1, 2, 3, 4, 5, 6, 7)
val in = new ByteArrayInputStream(bytes)
val v = ParameterBinder[InputStream](
value = in,
binder = (stmt: PreparedStatement, idx: Int) => {
stmt.setBinaryStream(idx, in, bytes.length)
}
)
sql"insert into table_name (data) values (${v})".update.apply()
```

#### Review Points

- Better names?
- Better solution?

I'd like to merge this PR within days before ScalikeJDBC 2.0.0 release.