From 614de4ec6e7266123fbb7a8029058c0c6f53f9ee Mon Sep 17 00:00:00 2001 From: Dylan Simon Date: Mon, 4 Nov 2013 23:27:50 -0500 Subject: [PATCH 1/2] Decode OIDs as Long Technically OIDs are uint32, so Int is a theoretically better choice, but this would not properly preserve the unsignedness, which would then confuse input. --- .../mauricio/async/db/postgresql/column/ColumnTypes.scala | 3 ++- .../postgresql/column/PostgreSQLColumnDecoderRegistry.scala | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/postgresql-async/src/main/scala/com/github/mauricio/async/db/postgresql/column/ColumnTypes.scala b/postgresql-async/src/main/scala/com/github/mauricio/async/db/postgresql/column/ColumnTypes.scala index 945b3019..e9a5e042 100644 --- a/postgresql-async/src/main/scala/com/github/mauricio/async/db/postgresql/column/ColumnTypes.scala +++ b/postgresql-async/src/main/scala/com/github/mauricio/async/db/postgresql/column/ColumnTypes.scala @@ -55,11 +55,12 @@ object ColumnTypes { final val IntervalArray = 1187 final val Boolean = 16 final val BooleanArray = 1000 + final val OID = 26 + final val OIDArray = 1028 final val ByteA = 17 final val ByteA_Array = 1001 - final val OIDArray = 1028 final val MoneyArray = 791 final val NameArray = 1003 final val UUIDArray = 2951 diff --git a/postgresql-async/src/main/scala/com/github/mauricio/async/db/postgresql/column/PostgreSQLColumnDecoderRegistry.scala b/postgresql-async/src/main/scala/com/github/mauricio/async/db/postgresql/column/PostgreSQLColumnDecoderRegistry.scala index 6b6ea7dd..734c0902 100644 --- a/postgresql-async/src/main/scala/com/github/mauricio/async/db/postgresql/column/PostgreSQLColumnDecoderRegistry.scala +++ b/postgresql-async/src/main/scala/com/github/mauricio/async/db/postgresql/column/PostgreSQLColumnDecoderRegistry.scala @@ -67,6 +67,9 @@ class PostgreSQLColumnDecoderRegistry( charset : Charset = CharsetUtil.UTF_8 ) e case ColumnTypes.Integer => IntegerEncoderDecoder case IntegerArray => this.integerArrayDecoder + case OID => LongEncoderDecoder + case OIDArray => this.longArrayDecoder + case ColumnTypes.Numeric => BigDecimalEncoderDecoder case NumericArray => this.bigDecimalArrayDecoder @@ -103,7 +106,6 @@ class PostgreSQLColumnDecoderRegistry( charset : Charset = CharsetUtil.UTF_8 ) e case Interval => PostgreSQLIntervalEncoderDecoder case IntervalArray => this.intervalArrayDecoder - case OIDArray => this.stringArrayDecoder case MoneyArray => this.stringArrayDecoder case NameArray => this.stringArrayDecoder case UUIDArray => this.stringArrayDecoder From 0f556e84ce3bdeb587cb1b43b029627d4649d3c6 Mon Sep 17 00:00:00 2001 From: Dylan Simon Date: Tue, 5 Nov 2013 11:59:51 -0500 Subject: [PATCH 2/2] Test pulling oids from a select --- .../async/db/postgresql/PostgreSQLConnectionSpec.scala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/postgresql-async/src/test/scala/com/github/mauricio/async/db/postgresql/PostgreSQLConnectionSpec.scala b/postgresql-async/src/test/scala/com/github/mauricio/async/db/postgresql/PostgreSQLConnectionSpec.scala index d1681586..47724a24 100644 --- a/postgresql-async/src/test/scala/com/github/mauricio/async/db/postgresql/PostgreSQLConnectionSpec.scala +++ b/postgresql-async/src/test/scala/com/github/mauricio/async/db/postgresql/PostgreSQLConnectionSpec.scala @@ -53,7 +53,7 @@ class PostgreSQLConnectionSpec extends Specification with DatabaseTestHelper { time_column time, boolean_column boolean, constraint bigserial_column_pkey primary key (bigserial_column) - )""" + ) with oids""" val insert = """insert into type_test_table ( smallint_column, @@ -83,7 +83,7 @@ class PostgreSQLConnectionSpec extends Specification with DatabaseTestHelper { ) """ - val select = "select * from type_test_table" + val select = "select *, oid from type_test_table" val preparedStatementCreate = """create temp table prepared_statement_test ( id bigserial not null, @@ -151,6 +151,8 @@ class PostgreSQLConnectionSpec extends Specification with DatabaseTestHelper { row(10) === DateEncoderDecoder.decode("1984-08-06") row(11) === TimeEncoderDecoder.Instance.decode("22:13:45.888888") row(12) === true + row(13) must beAnInstanceOf[java.lang.Long] + row(13).asInstanceOf[Long] must beGreaterThan(0L) }