From fe97908a1f95bdcbf680b094e2b318b0d8ce98b4 Mon Sep 17 00:00:00 2001 From: Ian O Connell Date: Mon, 10 Mar 2014 17:36:28 -0700 Subject: [PATCH] Bumping finagle to a more recent version, changes that were required --- project/Finagle.scala | 2 +- .../twitter/storehaus/mysql/ValueMapper.scala | 26 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/project/Finagle.scala b/project/Finagle.scala index b339bd98..bd9454cb 100644 --- a/project/Finagle.scala +++ b/project/Finagle.scala @@ -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) } diff --git a/storehaus-mysql/src/main/scala/com/twitter/storehaus/mysql/ValueMapper.scala b/storehaus-mysql/src/main/scala/com/twitter/storehaus/mysql/ValueMapper.scala index 9f15815e..c5f6a7af 100644 --- a/storehaus-mysql/src/main/scala/com/twitter/storehaus/mysql/ValueMapper.scala +++ b/storehaus-mysql/src/main/scala/com/twitter/storehaus/mysql/ValueMapper.scala @@ -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 @@ -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) @@ -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 @@ -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.") } } @@ -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))) } /** @@ -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] {