Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[postgres] DRAFT handling for PG types - return as Strings by the dri…

…ver API
  • Loading branch information...
commit b78fc5fe1c6254f2ccf9aebb04199d6f5439047e 1 parent cdf5a65
@kares kares authored
Showing with 23 additions and 1 deletion.
  1. +23 −1 src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java
View
24 src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java
@@ -30,6 +30,8 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
+import java.util.Collection;
+import java.util.HashSet;
import java.util.UUID;
import org.jruby.Ruby;
@@ -97,6 +99,21 @@ protected IRubyObject jdbcToRuby(final Ruby runtime,
return super.jdbcToRuby(runtime, column, type, resultSet);
}
+ // TODO this is just a fast-draft for now :
+ private static final Collection<String> PG_TYPES = new HashSet<String>();
+ static {
+ PG_TYPES.add("org.postgresql.util.PGobject");
+ PG_TYPES.add("org.postgresql.util.PGmoney");
+ PG_TYPES.add("org.postgresql.util.PGInterval");
+ PG_TYPES.add("org.postgresql.geometric.PGbox");
+ PG_TYPES.add("org.postgresql.geometric.PGcircle");
+ PG_TYPES.add("org.postgresql.geometric.PGline");
+ PG_TYPES.add("org.postgresql.geometric.PGlseg");
+ PG_TYPES.add("org.postgresql.geometric.PGpath");
+ PG_TYPES.add("org.postgresql.geometric.PGpoint");
+ PG_TYPES.add("org.postgresql.geometric.PGpolygon");
+ }
+
@Override
protected IRubyObject objectToRuby(
final Ruby runtime, final ResultSet resultSet, final Object object)
@@ -104,8 +121,13 @@ protected IRubyObject objectToRuby(
if ( object == null && resultSet.wasNull() ) return runtime.getNil();
if ( object.getClass() == UUID.class ) {
- return runtime.newString( ((UUID) object).toString() );
+ return runtime.newString( object.toString() );
}
+ // NOTE: this should get refactored using PG's JDBC API :
+ if ( PG_TYPES.contains(object.getClass().getName()) ) {
+ return runtime.newString( object.toString() );
+ }
+
return JavaUtil.convertJavaToRuby(runtime, object);
}
Please sign in to comment.
Something went wrong with that request. Please try again.