diff --git a/core/src/main/scala/scalikejdbc/async/internal/AsyncResultSetImpl.scala b/core/src/main/scala/scalikejdbc/async/internal/AsyncResultSetImpl.scala index 4d4cad9..0f219ed 100644 --- a/core/src/main/scala/scalikejdbc/async/internal/AsyncResultSetImpl.scala +++ b/core/src/main/scala/scalikejdbc/async/internal/AsyncResultSetImpl.scala @@ -38,7 +38,13 @@ private[scalikejdbc] class AsyncResultSetImpl(rows: IndexedSeq[RowData]) // WrappedResultSet API - override def any(columnIndex: Int): Any = currentRow.map(_.apply(columnIndex)).orNull[Any] + override def any(columnIndex: Int): Any = { + // To be compatible with JDBC, index should be 1-origin + // But postgresql-async/mysql-async is 0-origin + val index0origin = columnIndex - 1 + currentRow.map(_.apply(index0origin)).orNull[Any] + } + override def any(columnLabel: String): Any = currentRow.map(_.apply(columnLabel)).orNull[Any] override def bigDecimal(columnIndex: Int): java.math.BigDecimal = any(columnIndex) match { diff --git a/core/src/test/scala/sample/PostgreSQLSampleSpec.scala b/core/src/test/scala/sample/PostgreSQLSampleSpec.scala index 31187b3..bd575c0 100644 --- a/core/src/test/scala/sample/PostgreSQLSampleSpec.scala +++ b/core/src/test/scala/sample/PostgreSQLSampleSpec.scala @@ -13,6 +13,14 @@ class PostgreSQLSampleSpec extends FlatSpec with ShouldMatchers with DBSettings val createdTime = DateTime.now.withMillisOfSecond(0) val al = AsyncLover.syntax("al") + it should "count" in { + val countFuture: Future[Long] = AsyncDB.withPool { implicit s => + withSQL { select(sqls.count).from(AsyncLover as al) }.map(_.long(1)).single.future().map(_.get) + } + val c = Await.result(countFuture, 5.seconds) + c should be > 0L + } + it should "select a single value" in { val resultFuture: Future[Option[AsyncLover]] = AsyncDB.withPool { implicit s => withSQL { select.from(AsyncLover as al).where.eq(al.id, 1) }.map(AsyncLover(al)).single.future() diff --git a/project/Build.scala b/project/Build.scala index 3fb1488..6492a3b 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -4,7 +4,7 @@ import play.Project._ object ScalikeJDBCAsyncProject extends Build { - lazy val _version = "0.3.2" + lazy val _version = "0.3.3" lazy val scalikejdbcVersion = "1.7.0" lazy val mauricioVersion = "0.2.8" lazy val defaultPlayVersion = "2.2.1"