This repository has been archived by the owner on Jun 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
No support for binary #10
Comments
Anyway, I added support for read operations. Not git-saavy enough to actually push the changes up to github, but heres a diff: diff --git a/src/main/scala/net/noerd/prequel/ColumnTypes.scala b/src/main/scala/net/noerd/prequel/ColumnTypes.scala
index 5342948..3895f46 100644
--- a/src/main/scala/net/noerd/prequel/ColumnTypes.scala
+++ b/src/main/scala/net/noerd/prequel/ColumnTypes.scala
@@ -90,4 +90,15 @@ class DurationColumnType( row: ResultSetRow ) extends ColumnType[ Duration ] {
}
object DurationColumnType extends ColumnTypeFactory[ Duration ] {
def apply( row: ResultSetRow ) = new DurationColumnType( row )
-}
\ No newline at end of file
+}
+
+//
+// Binary
+//
+
+class BinaryColumnType( row: ResultSetRow ) extends ColumnType [ Array[Byte] ]{
+ override def nextValueOption: Option[ Array[Byte] ] = row.nextBinary
+}
+object BinaryColumnType extends ColumnTypeFactory[ Array[Byte] ] {
+ def apply( row: ResultSetRow ) = new BinaryColumnType( row )
+}
diff --git a/src/main/scala/net/noerd/prequel/ResultSetRow.scala b/src/main/scala/net/noerd/prequel/ResultSetRow.scala
index 7230ffa..643a7ab 100644
--- a/src/main/scala/net/noerd/prequel/ResultSetRow.scala
+++ b/src/main/scala/net/noerd/prequel/ResultSetRow.scala
@@ -28,7 +28,7 @@ class ResultSetRow( val rs: ResultSet ) {
def nextString: Option[ String ] = nextValueOption( rs.getString )
def nextDate: Option[ Date ] = nextValueOption( rs.getTimestamp )
def nextObject: Option[ AnyRef ] = nextValueOption( rs.getObject )
-
+ def nextBinary: Option[ Array[ Byte ] ] = nextValueOption( rs.getBytes )
def columnNames: Seq[ String ]= {
val columnNames = ArrayBuffer.empty[ String ]
val metaData = rs.getMetaData
@@ -80,6 +80,7 @@ object ResultSetRowImplicits {
implicit def row2Long( row: ResultSetRow ): Long = LongColumnType( row ).nextValue
implicit def row2Float( row: ResultSetRow ) = FloatColumnType( row ).nextValue
implicit def row2Double( row: ResultSetRow ) = DoubleColumnType( row ).nextValue
+ implicit def row2Binary( row: ResultSetRow ) = BinaryColumnType( row ).nextValue
implicit def row2String( row: ResultSetRow ) = StringColumnType( row ).nextValue
implicit def row2Date( row: ResultSetRow ) = DateColumnType( row ).nextValue
implicit def row2DateTime( row: ResultSetRow ) = DateTimeColumnType( row ).nextValue
@@ -90,6 +91,7 @@ object ResultSetRowImplicits {
implicit def row2LongOption( row: ResultSetRow ) = LongColumnType( row ).nextValueOption
implicit def row2FloatOption( row: ResultSetRow ) = FloatColumnType( row ).nextValueOption
implicit def row2DoubleOption( row: ResultSetRow ) = DoubleColumnType( row ).nextValueOption
+ implicit def row2BinaryOption( row: ResultSetRow ) = BinaryColumnType( row ).nextValueOption
implicit def row2StringOption( row: ResultSetRow ) = StringColumnType( row ).nextValueOption
implicit def row2DateOption( row: ResultSetRow ) = DateColumnType( row ).nextValueOption
implicit def row2DateTimeOption( row: ResultSetRow ) = DateTimeColumnType( row ).nextValueOption |
Hi there! Is it possible to merge this to master? I can make a pull request with @tylereaves changes if needed. |
I went ahead and made a pull request. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
There doesn't appear to be any support for binary/varbinary/blog type columns. This can be...annoying.
The text was updated successfully, but these errors were encountered: