Skip to content

Commit

Permalink
Bumping finagle to a more recent version, changes that were required
Browse files Browse the repository at this point in the history
  • Loading branch information
ianoc committed Mar 11, 2014
1 parent 119216e commit fe97908
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion project/Finagle.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package storehaus
* dependency */
object Finagle {
import sbt._
val LatestVersion = "6.5.1"
val LatestVersion = "6.12.2"
def module(name: String, version: String = LatestVersion) =
StorehausBuild.withCross("com.twitter" %% "finagle-%s".format(name) % version)
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ import com.twitter.finagle.exp.mysql.{
IntValue,
LongValue,
NullValue,
RawBinaryValue,
RawStringValue,
RawValue,
ShortValue,
StringValue,
Value
Value,
Charset,
Type
}

import org.jboss.netty.buffer.ChannelBuffer
Expand All @@ -46,16 +47,16 @@ object ValueMapper {
// INTEGER, INT, MEDIUMINT => IntValue
// BIGINT => LongValue
// SMALLINT => ShortValue
// BLOB => RawBinaryValue
// TEXT => RawStringValue
// BLOB => RawValue
// TEXT => RawValue
// CHAR/VARCHAR => StringValue

def toChannelBuffer(v: Value): Option[ChannelBuffer] = {
v match {
case IntValue(d) => Some(ChannelBuffers.copiedBuffer(d.toString, UTF_8))
case LongValue(d) => Some(ChannelBuffers.copiedBuffer(d.toString, UTF_8))
case RawBinaryValue(d) => Some(ChannelBuffers.copiedBuffer(d)) // from byte array
case RawStringValue(d) => Some(ChannelBuffers.copiedBuffer(d, UTF_8))
case RawValue(_,_, true, d) => Some(ChannelBuffers.copiedBuffer(d)) // from byte array
case RawValue(_, _, false, d) => Some(ChannelBuffers.copiedBuffer(new String(d), UTF_8))
case ShortValue(d) => Some(ChannelBuffers.copiedBuffer(d.toString, UTF_8))
case StringValue(d) => Some(ChannelBuffers.copiedBuffer(d, UTF_8))
case EmptyValue => Some(ChannelBuffers.EMPTY_BUFFER)
Expand All @@ -69,8 +70,7 @@ object ValueMapper {
v match {
case IntValue(v) => Some(v.toString)
case LongValue(v) => Some(v.toString)
case RawBinaryValue(v) => Some(new String(v)) // from byte array
case RawStringValue(v) => Some(v)
case RawValue(_, _, _, v) => Some(new String(v)) // from byte array
case ShortValue(v) => Some(v.toString)
case StringValue(v) => Some(v)
// finagle-mysql text protocol wraps null strings as NullValue
Expand All @@ -91,11 +91,11 @@ object ValueMapper {
object MySqlValue {
def apply(v: Any) = v match {
case v: Value => new MySqlValue(v)
case v: String => new MySqlValue(RawStringValue(v))
case v: String => new MySqlValue(RawValue(Type.String, Charset.Utf8_general_ci, false, v.getBytes))
case v: Int => new MySqlValue(IntValue(v))
case v: Long => new MySqlValue(LongValue(v))
case v: Short => new MySqlValue(ShortValue(v))
case v: ChannelBuffer => new MySqlValue(RawStringValue(v.toString(UTF_8)))
case v: ChannelBuffer => new MySqlValue(RawValue(Type.String, Charset.Utf8_general_ci, false, v.toString(UTF_8).getBytes))
case _ => throw new UnsupportedOperationException(v.getClass.getName + " is currently not supported.")
}
}
Expand Down Expand Up @@ -126,7 +126,7 @@ class MySqlValue(val v: Value) {
*/
object MySqlStringInjection extends Injection[MySqlValue, String] {
def apply(a: MySqlValue): String = ValueMapper.toString(a.v).getOrElse("") // should this be null: String instead?
override def invert(b: String) = Try(MySqlValue(RawStringValue(b)))
override def invert(b: String) = Try(MySqlValue(RawValue(Type.String, Charset.Utf8_general_ci, false, b.getBytes)))
}

/**
Expand All @@ -136,7 +136,7 @@ object MySqlStringInjection extends Injection[MySqlValue, String] {
*/
object MySqlCbInjection extends Injection[MySqlValue, ChannelBuffer] {
def apply(a: MySqlValue): ChannelBuffer = ValueMapper.toChannelBuffer(a.v).getOrElse(ChannelBuffers.EMPTY_BUFFER)
override def invert(b: ChannelBuffer) = Try(MySqlValue(RawStringValue(b.toString(UTF_8))))
override def invert(b: ChannelBuffer) = Try(MySqlValue((Type.String, Charset.Utf8_general_ci, false, b.toString(UTF_8))))
}

object LongMySqlInjection extends Injection[Long, MySqlValue] {
Expand Down

0 comments on commit fe97908

Please sign in to comment.