Skip to content
Permalink
Browse files

Do not advance PositionedResultIterator at the beginning of foreach().

Test case in InvokerTest.testCollections. Fixes issue #81.
  • Loading branch information
szeiger committed Dec 18, 2012
1 parent 360b098 commit 78d7b315779b155cc7effc815ce9ce3a97d09dca
@@ -48,6 +48,12 @@ class InvokerTest(val tdb: TestDB) extends TestkitTest {
val r6 = q.to[Array]
val r6t: Array[Int] = r6
assertEquals(Array(1, 2, 3, 4, 5).toList, r6.toList)

val it = q.elements
val sum = try {
it.reduceLeft(_ + _)
} finally it.close()
assertEquals(15, sum)
}

def testMap {
@@ -1,11 +1,11 @@
package scala.slick.session

import scala.language.higherKinds
import scala.collection.generic.CanBuildFrom
import java.sql.{ResultSet, Blob, Clob, Date, Time, Timestamp}
import java.io.Closeable
import scala.slick.jdbc.GetResult
import scala.slick.util.CloseableIterator
import collection.generic.CanBuildFrom

/**
* A database result positioned at a row and column.
@@ -209,5 +209,5 @@ abstract class PositionedResultIterator[+T](_rs: ResultSet, maxRows: Int) extend
protected def extractValue(): T
protected def closeUnderlying(): Unit

final override def foreach[U](f: T => U) { while(nextRow) f(extractValue()) }
final override def foreach[U](f: T => U) { while(hasNext) f(extractValue()) }
}

0 comments on commit 78d7b31

Please sign in to comment.
You can’t perform that action at this time.