Skip to content
Browse files

Fix intlist serilization

  • Loading branch information...
1 parent 203e994 commit 263f98f0d6396fdc8b9f95aab5e196e2e738563f @holdenk holdenk committed Jun 26, 2012
View
2 build.sbt
@@ -1,6 +1,6 @@
name := "slashem"
-version := "0.12.4"
+version := "0.12.5"
organization := "com.foursquare"
View
4 src/main/scala/com/foursquare/slashem/Schema.scala
@@ -992,7 +992,7 @@ class SlashemIntListField[T <: Record[T]](owner: T) extends IntListField[T](owne
case "" => Empty
case ar: Array[Int] => Full(ar.toList)
case ar: Array[Integer] => Full(ar.toList.map(x=>x.intValue))
- case ar: ArrayList[_] => Full(set(ar.toArray.asInstanceOf[Array[Int]].toList))
+ case ar: ArrayList[_] => Full(set(ar.toArray.toList.map(x=>x.asInstanceOf[Integer].intValue)))
case s: String => Full(s.split(" ").map(x => x.toInt).toList)
case _ => Empty
}
@@ -1227,7 +1227,7 @@ class IntListField[T <: Record[T]](override val owner: T) extends Field[List[Int
case "" => Empty
case ar: Array[Int] => Full(set(ar.toList))
case ar: Array[Integer] => Full(set(ar.toList.map(x=>x.intValue)))
- case ar: ArrayList[_] => Full(set(ar.toArray.asInstanceOf[Array[Int]].toList))
+ case ar: ArrayList[_] => Full(set(ar.toArray.toList.map(x=>x.asInstanceOf[Integer].intValue)))
case s: String => Full(set(s.split(" ").map(x => x.toInt).toList))
case _ => Empty
}
View
7 src/test/scala/com/foursquare/slashem/ElasticQueryTest.scala
@@ -354,6 +354,13 @@ class ElasticQueryTest extends SpecsMatchers with ScalaCheckMatchers {
}
@Test
+ def testIntListFieldReturn {
+ val response1 = ESimplePanda where (_.favnums contains 2) fetch()
+ Assert.assertEquals(response1.response.results.length, 2)
+ Assert.assertEquals(response1.response.results.head.favnums.get, List(1,2,3,4,5))
+ }
+
+ @Test
def testListFieldIn {
val response1 = ESimplePanda where (_.favnums in List(2, 3, 4, 5)) fetch()
val response2 = ESimplePanda where (_.favnums in List(99)) fetch()

0 comments on commit 263f98f

Please sign in to comment.
Something went wrong with that request. Please try again.