Hello
,
I have the following schema

/* ----------------------------------
 * Clear and create schema
 * ----------------------------------
 */
DROP SCHEMA IF EXISTS  myschema CASCADE;
CREATE SCHEMA myschema;

/* ----------------------------------
 *  Enumeration: testenum
 * ----------------------------------
 */
 DROP TYPE  IF EXISTS  myschema.testenum;
  CREATE TYPE myschema.testenum AS ENUM ('val1', 'val2', 'val3');

/* ----------------------------------
 * Table: base object
 * ----------------------------------
 */
CREATE TABLE myschema.table1 (
    id int8 NOT NULL,
      enumval   myschema.testenum,
    
    CONSTRAINT primary_base_object PRIMARY KEY (id)
);

I have generated the classes with jOOQ. 
The enum looks as follows:

public enum Testenum implements org.jooq.EnumType {
    val1("val1"),

    val2("val2"),

    val3("val3"),

    ;

    private final java.lang.String literal;

    private Testenum(java.lang.String literal) {
        this.literal = literal;
    }

    @Override
    public java.lang.String getName() {
        return "testenum";
    }

    @Override
    public java.lang.String getLiteral() {
        return literal;
    }
}

So there is no information about the schema "myschema". As it is for the 
generated table class.

The following insert fails:

Factory f = new Factory(con, SQLDialect.POSTGRES);
f.insertInto(Table1.TABLE1).values(f.val(1), Testenum.val1).execute();
Result<Record> result = f.select().from(Table1.TABLE1).fetch();
System.out.println(result);

Error:

SQL [insert into "myschema"."table1" ("id", "enumval") values (?, 
?::"testenum")]; FEHLER: Typ »testenum« existiert nicht

(Error message from German to English: "ERROR: Type »testenum« does not 
exist")

If I move "testenum" is in the public schema, everything is fine!

Now my question: Is there the possibility to add schema information to the 
enum type?

Regards,
Marcel


Reply via email to