Skip to content

Commit

Permalink
Fix forceInsertAll for single argument
Browse files Browse the repository at this point in the history
  • Loading branch information
zczapran committed Aug 12, 2014
1 parent f0bc906 commit b0b0252
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ class InsertTest extends TestkitTest[JdbcTestDB] {
ts.forceInsert(104, "A") ts.forceInsert(104, "A")
ts.map(_.ins).forceInsertAll((105, "B"), (106, "C")) ts.map(_.ins).forceInsertAll((105, "B"), (106, "C"))
assertEquals(3, ts.filter(_.id > 100).length.run) assertEquals(3, ts.filter(_.id > 100).length.run)
ts.map(_.ins).forceInsertAll((111, "D"))
assertEquals(4, ts.filter(_.id > 100).length.run)
} }
} }


Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ trait JdbcInsertInvokerComponent extends BasicInsertInvokerComponent{ driver: Jd
final def forceInsertAll(values: U*)(implicit session: Backend#Session): MultiInsertResult = internalInsertAll(compiled.forceInsert, values: _*) final def forceInsertAll(values: U*)(implicit session: Backend#Session): MultiInsertResult = internalInsertAll(compiled.forceInsert, values: _*)


protected def internalInsertAll(a: compiled.Artifacts, values: U*)(implicit session: Backend#Session): MultiInsertResult = session.withTransaction { protected def internalInsertAll(a: compiled.Artifacts, values: U*)(implicit session: Backend#Session): MultiInsertResult = session.withTransaction {
if(!useBatchUpdates || (values.isInstanceOf[IndexedSeq[_]] && values.length < 2)) retMany(values, values.map(insert)) if(!useBatchUpdates || (values.isInstanceOf[IndexedSeq[_]] && values.length < 2))
retMany(values, values.map(v => internalInsert(a, v)))
else preparedInsert(a.sql) { st => else preparedInsert(a.sql) { st =>
st.clearParameters() st.clearParameters()
for(value <- values) { for(value <- values) {
Expand Down

0 comments on commit b0b0252

Please sign in to comment.