@@ -74,12 +74,7 @@ class MongoDbResultSet(collectionDao: MongoDAO[Document], data: List[Document],
7474
7575 override def getLong (columnIndex : Int ): Long = {
7676 checkClosed()
77- val value = currentRow.getValue(metaData.getColumnName(columnIndex))
78- value match {
79- case b : BsonInt32 => b.longValue()
80- case b : BsonInt64 => b.longValue()
81- case _ => Option (value).flatMap(v => Try (v.toString.toLong).toOption).getOrElse(0 )
82- }
77+ getDouble(columnIndex).toLong
8378 }
8479
8580 override def getFloat (columnIndex : Int ): Float = {
@@ -89,7 +84,13 @@ class MongoDbResultSet(collectionDao: MongoDAO[Document], data: List[Document],
8984
9085 override def getDouble (columnIndex : Int ): Double = {
9186 checkClosed()
92- currentRow.getDouble(metaData.getColumnName(columnIndex))
87+ val value = currentRow.getValue(metaData.getColumnName(columnIndex))
88+ value match {
89+ case b : BsonInt32 => b.doubleValue()
90+ case b : BsonInt64 => b.doubleValue()
91+ case b : BsonDouble => b.doubleValue()
92+ case _ => Option (value).flatMap(v => v.toString.toDoubleOption).getOrElse(0 )
93+ }
9394 }
9495
9596 override def getBigDecimal (columnIndex : Int , scale : Int ): java.math.BigDecimal = {
@@ -99,7 +100,7 @@ class MongoDbResultSet(collectionDao: MongoDAO[Document], data: List[Document],
99100
100101 override def getBytes (columnIndex : Int ): Array [Byte ] = {
101102 checkClosed()
102- null
103+ getString(columnIndex).replace( " [ " , " " ).replace( " ] " , " " ).split( " , " ).filterNot(s => s.trim.isEmpty).map(_.trim.toByte)
103104 }
104105
105106 override def getDate (columnIndex : Int ): Date = {
@@ -142,7 +143,7 @@ class MongoDbResultSet(collectionDao: MongoDAO[Document], data: List[Document],
142143 value match {
143144 case v : BsonString => v.getValue
144145 case v : BsonObjectId => v.asObjectId().getValue.toHexString
145- case _ => BsonConverter .fromBson(value). toString
146+ case _ => Option ( BsonConverter .fromBson(value)).map(_. toString).orNull
146147 }
147148 case None => " "
148149 }
@@ -165,12 +166,12 @@ class MongoDbResultSet(collectionDao: MongoDAO[Document], data: List[Document],
165166
166167 override def getInt (columnLabel : String ): Int = {
167168 checkClosed()
168- currentRow.getIntValue (columnLabel)
169+ getDouble (columnLabel).toInt
169170 }
170171
171172 override def getLong (columnLabel : String ): Long = {
172173 checkClosed()
173- currentRow.getLong (columnLabel)
174+ getDouble (columnLabel).toLong
174175 }
175176
176177 override def getFloat (columnLabel : String ): Float = {
@@ -180,7 +181,13 @@ class MongoDbResultSet(collectionDao: MongoDAO[Document], data: List[Document],
180181
181182 override def getDouble (columnLabel : String ): Double = {
182183 checkClosed()
183- currentRow.getDouble(columnLabel)
184+ val value = currentRow.getValue(columnLabel)
185+ value match {
186+ case b : BsonInt32 => b.doubleValue()
187+ case b : BsonInt64 => b.doubleValue()
188+ case b : BsonDouble => b.doubleValue()
189+ case _ => Option (value).flatMap(v => v.toString.toDoubleOption).getOrElse(0 )
190+ }
184191 }
185192
186193 override def getBigDecimal (columnLabel : String , scale : Int ): java.math.BigDecimal = {
0 commit comments