pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Array of UUID is not supported
5+ messages / 2 participants
[nested] [flat]

* Array of UUID is not supported
@ 2013-10-10 18:39 Martin Petras <Martin.Petras@coresystems.ch>
  2013-10-11 11:38 ` Re: Array of UUID is not supported Martin Petras <Martin.Petras@coresystems.ch>
  0 siblings, 1 reply; 5+ messages in thread

From: Martin Petras @ 2013-10-10 18:39 UTC (permalink / raw)
  To: pgsql-jdbc

Hey guys,

First of all, thanks a lot for working on the PG JDBC driver!

By using the driver version 9.2-1003-jdbc4 I'm not able to retrieve a column of type UUID[]. The error description is below.

I'm using PG 9.3, version 'PostgreSQL 9.3.0 on x86_64-apple-darwin12.5.0, compiled by Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn), 64-bit' under Mac OS 10.8.5.

Steps to reproduce:
1) run the following queries:
CREATE TABLE uuids (id UUID NOT NULL, ids UUID []);
insert into uuids values ('a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11', '{a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11,a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a12}');

2) run java code:
Class.forName( "org.postgresql.Driver"); // load the driver
Connection db = DriverManager.getConnection("jdbc:postgresql://localhost:7432/test", "postgres", "postgres");
PreparedStatement ps = db.prepareStatement("select * from uuids");
ResultSet rs = ps.executeQuery();
while(rs.next()) {
UUID id = (UUID) rs.getObject("id");
Array ids = rs.getArray("ids");
System.out.println(id + "\t" + ids + "\t" + ids.getArray()); // fails on ids.getArray()
}
rs.close();
ps.close();
db.close();

Expected: ids are a proper array of java.util.UUID objects
Current:
Exception in thread "main" java.sql.SQLFeatureNotSupportedException: Method org.postgresql.jdbc4.Jdbc4Array.getArrayImpl(long,int,Map) is not yet implemented.
at org.postgresql.Driver.notImplemented(Driver.java:710)
at org.postgresql.jdbc2.AbstractJdbc2Array.buildArray(AbstractJdbc2Array.java:745)
at org.postgresql.jdbc2.AbstractJdbc2Array.getArrayImpl(AbstractJdbc2Array.java:171)
at org.postgresql.jdbc2.AbstractJdbc2Array.getArray(AbstractJdbc2Array.java:128)


After quick look in the code around org/postgresql/jdbc2/AbstractJdbc2Array.java:745, it seems that there are two problems:
1) type of objects in the array is resolved to java.sql.Types#OTHER
2) if it is possible to resolve the type to find out it's UUID, it's just up to call UUID.fromString( for each entry in 'input') as input already contains string representations of UUIDs

I hope you'll find some time to fix it as I'd love to use the feature in my project.

Thanks and cheers,

Martin Petras

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Array of UUID is not supported
  2013-10-10 18:39 Array of UUID is not supported Martin Petras <Martin.Petras@coresystems.ch>
@ 2013-10-11 11:38 ` Martin Petras <Martin.Petras@coresystems.ch>
  2013-11-01 09:14   ` Re: Array of UUID is not supported Martin Petras <Martin.Petras@coresystems.ch>
  0 siblings, 1 reply; 5+ messages in thread

From: Martin Petras @ 2013-10-11 11:38 UTC (permalink / raw)
  To: pgsql-jdbc; +Cc: Martin Petras <Martin.Petras@coresystems.ch>

Hey guys,

There is a pull request containing the fix: https://github.com/pgjdbc/pgjdbc/pull/81

It would be great to have it review and merged to the master branch.

Cheers,

Martin Petras

From: Martin Petras <martin.petras@coresystems.ch<mailto:martin.petras@coresystems.ch>>
Date: štvrtok, 10. októbra 2013 20:39
To: "pgsql-jdbc@postgresql.org<mailto:pgsql-jdbc@postgresql.org>" <pgsql-jdbc@postgresql.org<mailto:pgsql-jdbc@postgresql.org>>
Subject: [JDBC] Array of UUID is not supported

Hey guys,

First of all, thanks a lot for working on the PG JDBC driver!

By using the driver version 9.2-1003-jdbc4 I'm not able to retrieve a column of type UUID[]. The error description is below.

I'm using PG 9.3, version 'PostgreSQL 9.3.0 on x86_64-apple-darwin12.5.0, compiled by Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn), 64-bit' under Mac OS 10.8.5.

Steps to reproduce:
1) run the following queries:
CREATE TABLE uuids (id UUID NOT NULL, ids UUID []);
insert into uuids values ('a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11', '{a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11,a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a12}');

2) run java code:
Class.forName( "org.postgresql.Driver"); // load the driver
Connection db = DriverManager.getConnection("jdbc:postgresql://localhost:7432/test", "postgres", "postgres");
PreparedStatement ps = db.prepareStatement("select * from uuids");
ResultSet rs = ps.executeQuery();
while(rs.next()) {
UUID id = (UUID) rs.getObject("id");
Array ids = rs.getArray("ids");
System.out.println(id + "\t" + ids + "\t" + ids.getArray()); // fails on ids.getArray()
}
rs.close();
ps.close();
db.close();

Expected: ids are a proper array of java.util.UUID objects
Current:
Exception in thread "main" java.sql.SQLFeatureNotSupportedException: Method org.postgresql.jdbc4.Jdbc4Array.getArrayImpl(long,int,Map) is not yet implemented.
at org.postgresql.Driver.notImplemented(Driver.java:710)
at org.postgresql.jdbc2.AbstractJdbc2Array.buildArray(AbstractJdbc2Array.java:745)
at org.postgresql.jdbc2.AbstractJdbc2Array.getArrayImpl(AbstractJdbc2Array.java:171)
at org.postgresql.jdbc2.AbstractJdbc2Array.getArray(AbstractJdbc2Array.java:128)


After quick look in the code around org/postgresql/jdbc2/AbstractJdbc2Array.java:745, it seems that there are two problems:
1) type of objects in the array is resolved to java.sql.Types#OTHER
2) if it is possible to resolve the type to find out it's UUID, it's just up to call UUID.fromString( for each entry in 'input') as input already contains string representations of UUIDs

I hope you'll find some time to fix it as I'd love to use the feature in my project.

Thanks and cheers,

Martin Petras

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Array of UUID is not supported
  2013-10-10 18:39 Array of UUID is not supported Martin Petras <Martin.Petras@coresystems.ch>
  2013-10-11 11:38 ` Re: Array of UUID is not supported Martin Petras <Martin.Petras@coresystems.ch>
@ 2013-11-01 09:14   ` Martin Petras <Martin.Petras@coresystems.ch>
  2013-11-01 09:30     ` Re: Array of UUID is not supported Dave Cramer <pg@fastcrypt.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Martin Petras @ 2013-11-01 09:14 UTC (permalink / raw)
  To: pgsql-jdbc

Hi guys,

I noticed that the pull request https://github.com/pgjdbc/pgjdbc/pull/81 had already been merged. Thanks a lot to Minglei Tu and Dave Cramer!

Do you have any plan or idea when you might release the new version of the driver?

Thx.

Cheers,

Martin Petras

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Array of UUID is not supported
  2013-10-10 18:39 Array of UUID is not supported Martin Petras <Martin.Petras@coresystems.ch>
  2013-10-11 11:38 ` Re: Array of UUID is not supported Martin Petras <Martin.Petras@coresystems.ch>
  2013-11-01 09:14   ` Re: Array of UUID is not supported Martin Petras <Martin.Petras@coresystems.ch>
@ 2013-11-01 09:30     ` Dave Cramer <pg@fastcrypt.com>
  2013-11-01 14:22       ` Re: Array of UUID is not supported Martin Petras <Martin.Petras@coresystems.ch>
  0 siblings, 1 reply; 5+ messages in thread

From: Dave Cramer @ 2013-11-01 09:30 UTC (permalink / raw)
  To: Martin Petras <Martin.Petras@coresystems.ch>; +Cc: pgsql-jdbc

Martin,

Snapshots are on maven, I am hoping to get a new driver released today
actually.

Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca


On Fri, Nov 1, 2013 at 5:14 AM, Martin Petras
<Martin.Petras@coresystems.ch>wrote:

>  Hi guys,
>
>  I noticed that the pull request https://github.com/pgjdbc/pgjdbc/pull/81 had
> already been merged. Thanks a lot to Minglei Tu and Dave Cramer!
>
>  Do you have any plan or idea when you might release the new version of
> the driver?
>
>  Thx.
>
>  Cheers,
>
>  Martin Petras
>
>

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Array of UUID is not supported
  2013-10-10 18:39 Array of UUID is not supported Martin Petras <Martin.Petras@coresystems.ch>
  2013-10-11 11:38 ` Re: Array of UUID is not supported Martin Petras <Martin.Petras@coresystems.ch>
  2013-11-01 09:14   ` Re: Array of UUID is not supported Martin Petras <Martin.Petras@coresystems.ch>
  2013-11-01 09:30     ` Re: Array of UUID is not supported Dave Cramer <pg@fastcrypt.com>
@ 2013-11-01 14:22       ` Martin Petras <Martin.Petras@coresystems.ch>
  0 siblings, 0 replies; 5+ messages in thread

From: Martin Petras @ 2013-11-01 14:22 UTC (permalink / raw)
  To: pgsql-jdbc

Perfect! Thanks!

^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2013-11-01 14:22 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-10-10 18:39 Array of UUID is not supported Martin Petras <Martin.Petras@coresystems.ch>
2013-10-11 11:38 ` Martin Petras <Martin.Petras@coresystems.ch>
2013-11-01 09:14   ` Martin Petras <Martin.Petras@coresystems.ch>
2013-11-01 09:30     ` Dave Cramer <pg@fastcrypt.com>
2013-11-01 14:22       ` Martin Petras <Martin.Petras@coresystems.ch>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox