Skip to content

Commit

Permalink
Merge pull request #48 from xuwei-k/refactoring
Browse files Browse the repository at this point in the history
some refactoring
  • Loading branch information
seratch committed Apr 3, 2017
2 parents eb464b5 + c50858e commit c3f5d65
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Expand Up @@ -29,7 +29,7 @@ private[scalikejdbc] class AsyncResultSetImpl(rows: IndexedSeq[RowData])
with AsyncResultSet {

// AsyncResultSet API
override def next(): Boolean = rows.headOption.isDefined
override def next(): Boolean = rows.nonEmpty
override def tail(): AsyncResultSet = new AsyncResultSetImpl(rows.tail)

}
Expand Up @@ -317,7 +317,7 @@ private[scalikejdbc] class RowDataResultSet(var currentRow: Option[RowData], var
val ref = getObject(columnIndex)

if (ref != null && `type`.isInstance(ref)) {
return ref.asInstanceOf[T]
ref.asInstanceOf[T]
} else {
throw new SQLException(s"Object of class ${ref.getClass} is not an instance of ${`type`}");
}
Expand All @@ -327,7 +327,7 @@ private[scalikejdbc] class RowDataResultSet(var currentRow: Option[RowData], var
val ref = getObject(columnLabel)

if (ref != null && `type`.isInstance(ref)) {
return ref.asInstanceOf[T]
ref.asInstanceOf[T]
} else {
throw new SQLException(s"Object of class ${ref.getClass} is not an instance of ${`type`}");
}
Expand Down
Expand Up @@ -37,7 +37,7 @@ trait MySQLConnectionImpl extends AsyncConnectionCommonImpl {
override protected def extractGeneratedKey(queryResult: QueryResult)(implicit cxt: EC = ECGlobal): Future[Option[Long]] = {
ensureNonShared()
underlying.sendQuery("SELECT LAST_INSERT_ID()").map { result =>
result.rows.headOption.flatMap { rows =>
result.rows.flatMap { rows =>
rows.headOption.map { row => row(0).asInstanceOf[Long] }
}
}
Expand Down
Expand Up @@ -38,7 +38,7 @@ trait PostgreSQLConnectionImpl extends AsyncConnectionCommonImpl {
protected def extractGeneratedKey(queryResult: QueryResult)(implicit cxt: EC = ECGlobal): Future[Option[Long]] = {
ensureNonShared()
Future.successful(for {
rows <- queryResult.rows.headOption
rows <- queryResult.rows
row <- rows.headOption
value <- Option(row(0))
key <- Try(value.toString.toLong).toOption
Expand Down

0 comments on commit c3f5d65

Please sign in to comment.