I have an enum array column in postgres 9.3, like this:
CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy');
CREATE TABLE test_enum_array
(
"eArray" mood[]
)
Jooq 3.3.1 correctly maps this during the generation process
to enums.Mood[] where Mood is a generated enum. Jooq also selects the data
from the database correctly.
However, when inserting via create.insertInto(new MyRecord(..., new Mood[]
{...},...)), I get the following exception:
ERROR: column "eArray" is of type mood[] but expression is of type
character varying[]
Hint: You will need to rewrite or cast the expression.
Position: 146
at org.jooq.impl.Utils.translate(Utils.java:1288)
at
org.jooq.impl.DefaultExecuteContext.sqlException(DefaultExecuteContext.java:495)
at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:327)
at
org.jooq.impl.AbstractDelegatingQuery.execute(AbstractDelegatingQuery.java:140)
at persistence.pgsql.PointsDao.earnPoints(PointsDao.scala:54)
at boot.Boot$delayedInit$body.apply(Boot.scala:55)
at scala.Function0$class.apply$mcV$sp(Function0.scala:40)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App$$anonfun$main$1.apply(App.scala:71)
at scala.App$$anonfun$main$1.apply(App.scala:71)
at scala.collection.immutable.List.foreach(List.scala:318)
at
scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:32)
at scala.App$class.main(App.scala:71)
at boot.Boot$.main(Boot.scala:23)
at boot.Boot.main(Boot.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Caused by: org.postgresql.util.PSQLException: ERROR: column "eArray" is of
type mood[] but expression is of type character varying[]
Hint: You will need to rewrite or cast the expression.
Position: 146
at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2161)
at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1890)
at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:559)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:417)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:410)
at
com.jolbox.bonecp.PreparedStatementHandle.execute(PreparedStatementHandle.java:140)
at
org.jooq.tools.jdbc.DefaultPreparedStatement.execute(DefaultPreparedStatement.java:194)
at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:382)
at org.jooq.impl.AbstractStoreQuery.execute(AbstractStoreQuery.java:289)
at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:323)
... 17 more
When printing the SQL generated by JOOQ, it looks like the value does
indeed have a specific cast to varchar[]:
insert into "myschema"."test_enum_array" ("eArray") values (?::varchar[])
Is this a bug? Is there a workaround?
Regards,
Raman
--
You received this message because you are subscribed to the Google Groups "jOOQ
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.