Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ class MySQLConnection(
override def eventLoopGroup : EventLoopGroup = group

def connect: Future[Connection] = {
this.connectionHandler.connect.onFailure {
case e => this.connectionPromise.tryFailure(e)
this.connectionHandler.connect.onComplete {
case Failure(e) => this.connectionPromise.tryFailure(e)
}

this.connectionPromise.future
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package com.github.mauricio.async.db.mysql.codec
import java.net.InetSocketAddress
import java.nio.ByteBuffer
import java.util.concurrent.TimeUnit

import com.github.mauricio.async.db.Configuration
import com.github.mauricio.async.db.exceptions.DatabaseException
import com.github.mauricio.async.db.general.MutableResultSet
Expand All @@ -39,6 +38,7 @@ import scala.annotation.switch
import scala.collection.mutable.{ArrayBuffer, HashMap}
import scala.concurrent._
import scala.concurrent.duration.Duration
import scala.util.Failure

class MySQLConnectionHandler(
configuration: Configuration,
Expand Down Expand Up @@ -84,8 +84,8 @@ class MySQLConnectionHandler(
this.bootstrap.option[java.lang.Boolean](ChannelOption.SO_KEEPALIVE, true)
this.bootstrap.option[ByteBufAllocator](ChannelOption.ALLOCATOR, LittleEndianByteBufAllocator.INSTANCE)

this.bootstrap.connect(new InetSocketAddress(configuration.host, configuration.port)).onFailure {
case exception => this.connectionPromise.tryFailure(exception)
this.bootstrap.connect(new InetSocketAddress(configuration.host, configuration.port)).onComplete {
case Failure(exception) => this.connectionPromise.tryFailure(exception)
}

this.connectionPromise.future
Expand Down Expand Up @@ -143,7 +143,7 @@ class MySQLConnectionHandler(
}
case ServerMessage.BinaryRow => {
val message = m.asInstanceOf[BinaryRowMessage]
this.currentQuery.addRow( this.binaryRowDecoder.decode(message.buffer, this.currentColumns ))
this.currentQuery.addRow( this.binaryRowDecoder.decode(message.buffer, this.currentColumns.toSeq ))
}
case ServerMessage.ParamProcessingFinished => {
}
Expand Down Expand Up @@ -201,7 +201,7 @@ class MySQLConnectionHandler(

this.parsedStatements.get(preparedStatement.statement) match {
case Some( item ) => {
this.executePreparedStatement(item.statementId, item.columns.size, preparedStatement.values, item.parameters)
this.executePreparedStatement(item.statementId, item.columns.size, preparedStatement.values, item.parameters.toSeq)
}
case None => {
decoder.preparedStatementPrepareStarted()
Expand Down Expand Up @@ -305,15 +305,15 @@ class MySQLConnectionHandler(
this.currentColumns
}

this.currentQuery = new MutableResultSet[ColumnDefinitionMessage](columns)
this.currentQuery = new MutableResultSet[ColumnDefinitionMessage](columns.toIndexedSeq)

if ( this.currentPreparedStatementHolder != null ) {
this.parsedStatements.put( this.currentPreparedStatementHolder.statement, this.currentPreparedStatementHolder )
this.executePreparedStatement(
this.currentPreparedStatementHolder.statementId,
this.currentPreparedStatementHolder.columns.size,
this.currentPreparedStatement.values,
this.currentPreparedStatementHolder.parameters
this.currentPreparedStatementHolder.parameters.toSeq
)
this.currentPreparedStatementHolder = null
this.currentPreparedStatement = null
Expand All @@ -324,8 +324,8 @@ class MySQLConnectionHandler(
if ( this.currentContext.channel().isActive ) {
val res = this.currentContext.writeAndFlush(message)

res.onFailure {
case e : Throwable => handleException(e)
res.onComplete {
case Failure(e) => handleException(e)
}

res
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,10 @@ class ResultSetRowMessage
buffer.update(n, newelem)
}

def +=(elem: ByteBuf): this.type = {
this.buffer += elem
this
}

def clear() {
this.buffer.clear()
}

def +=:(elem: ByteBuf): this.type = {
this.buffer.+=:(elem)
this
}

def insertAll(n: Int, elems: Traversable[ByteBuf]) {
this.buffer.insertAll(n, elems)
}
Expand All @@ -59,4 +49,24 @@ class ResultSetRowMessage

override def iterator: Iterator[ByteBuf] = this.buffer.iterator

override def prepend(elem: ByteBuf): ResultSetRowMessage.this.type = {
buffer.prepend(elem)
this
}

override def insert(idx: Int, elem: ByteBuf): Unit = buffer.insert(idx, elem)

override def insertAll(idx: Int, elems: IterableOnce[ByteBuf]): Unit = buffer.insertAll(idx, elems)

override def remove(idx: Int, count: Int): Unit = buffer.remove(idx, count)

override def patchInPlace(from: Int, patch: IterableOnce[ByteBuf], replaced: Int): ResultSetRowMessage.this.type = {
buffer.patchInPlace(from, patch, replaced)
this
}

override def addOne(elem: ByteBuf): ResultSetRowMessage.this.type = {
buffer.addOne(elem)
this
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import com.github.mauricio.async.db.column._
import io.netty.buffer.ByteBuf
import org.joda.time._

import scala.collection.JavaConversions._
import scala.collection.p._

object PostgreSQLColumnEncoderRegistry {
val Instance = new PostgreSQLColumnEncoderRegistry()
Expand Down Expand Up @@ -107,7 +107,7 @@ class PostgreSQLColumnEncoderRegistry extends ColumnEncoderRegistry {
encoder.get._1.encode(value)
} else {
value match {
case i: java.lang.Iterable[_] => encodeArray(i.toIterable)
case i: java.lang.Iterable[_] => encodeArray(i.toTraversable)
case i: Traversable[_] => encodeArray(i)
case i: Array[_] => encodeArray(i.toIterable)
case p: Product => encodeComposite(p)
Expand Down
20 changes: 12 additions & 8 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ object ProjectBuild extends Build {
settings = Configuration.baseSettings ++ Seq(
publish := (),
publishLocal := (),
publishArtifact := false
publishArtifact := false,
scalaVersion := Configuration.projectScalaVersion
),
aggregate = Seq(common, postgresql, mysql)
)
Expand All @@ -23,7 +24,8 @@ object ProjectBuild extends Build {
base = file(commonName),
settings = Configuration.baseSettings ++ Seq(
name := commonName,
libraryDependencies ++= Configuration.commonDependencies
libraryDependencies ++= Configuration.commonDependencies,
scalaVersion := Configuration.projectScalaVersion
)
)

Expand All @@ -32,7 +34,8 @@ object ProjectBuild extends Build {
base = file(postgresqlName),
settings = Configuration.baseSettings ++ Seq(
name := postgresqlName,
libraryDependencies ++= Configuration.implementationDependencies
libraryDependencies ++= Configuration.implementationDependencies,
scalaVersion := Configuration.projectScalaVersion
)
) dependsOn (common)

Expand All @@ -41,17 +44,18 @@ object ProjectBuild extends Build {
base = file(mysqlName),
settings = Configuration.baseSettings ++ Seq(
name := mysqlName,
libraryDependencies ++= Configuration.implementationDependencies
libraryDependencies ++= Configuration.implementationDependencies,
scalaVersion := Configuration.projectScalaVersion
)
) dependsOn (common)

}

object Configuration {

val commonVersion = "0.2.22-SNAPSHOT"
val projectScalaVersion = "2.12.1"
val specs2Version = "3.8.6"
val commonVersion = "0.2.21"
val projectScalaVersion = "2.13.8"
val specs2Version = "4.5.1"

val specs2Dependency = "org.specs2" %% "specs2-core" % specs2Version % "test"
val specs2JunitDependency = "org.specs2" %% "specs2-junit" % specs2Version % "test"
Expand Down Expand Up @@ -84,7 +88,7 @@ object Configuration {
,
testOptions in Test += Tests.Argument(TestFrameworks.Specs2, "sequential"),
scalacOptions in doc := Seq("-doc-external-doc:scala=http://www.scala-lang.org/archives/downloads/distrib/files/nightly/docs/library/"),
crossScalaVersions := Seq(projectScalaVersion, "2.10.6", "2.11.8"),
crossScalaVersions := Seq(projectScalaVersion),
javacOptions := Seq("-source", "1.6", "-target", "1.6", "-encoding", "UTF8"),
organization := "com.github.mauricio",
version := commonVersion,
Expand Down