Bug: enum types in schema other than public and Connection.createArrayOf - Mailing list pgsql-jdbc

From Hans Klett
Subject Bug: enum types in schema other than public and Connection.createArrayOf
Date
Msg-id C4746C300EA2D34FAF7805BBA5F4F5F9919A80F6@reactor.sldomain.com
Whole thread Raw
List pgsql-jdbc
Hello,

I found an issue with Connection.createArrayOf() when using qualified
enum type names. It doesn't like the qualified type name, and when you
give it the unqualified type name it just picks an enum type even if it's not
in the public schema. If the enum type name exists in multiple schemas it just
picks one, seemingly at random.

For instance, in database foo:
CREATE SCHEMA bar;
CREATE SCHEMA baz;
CREATE TYPE bar.mood AS ENUM ('happy', 'sad');
CREATE TYPE baz.mood AS ENUM ('grumpy', 'sassy');

Java:
    final Properties props = new Properties();
    props.setProperty("user", "postgres");
    props.setProperty("password", "postgres");
    try (final Connection conn = DriverManager.getConnection("jdbc:postgresql:foo", props)) {
        final String[] strings = { "sad", "happy" };

        // Works, but picks either baz.mood or bar.mood.
        // I haven't figured out how it picks which one to use.
        conn.createArrayOf("mood", strings);

        // Throws org.postgresql.util.PSQLException:
        //        Unable to find server array type for provided name bar.mood
        conn.createArrayOf("bar.mood", strings);
    }

Thanks!
- Hans


pgsql-jdbc by date:

Previous
From: Alexis Meneses
Date:
Subject: Re: Patch to allow setting schema/search_path in the connectionURL
Next
From: cowwoc
Date:
Subject: Why is version 9.3-1102 missing Connection.getSchema() support?