Hi,

there seems to be a bug regarding enum generation (probably only related to 
MySQL), when custom forcedType with <type> filter is configured.

My configuration file:

<configuration xmlns='http://www.jooq.org/xsd/jooq-codegen-3.6.0.xsd'>
  <jdbc>
    <driver>com.mysql.jdbc.Driver</driver>
    <url>jdbc:mysql://127.0.0.1:3306/myschema</url>
    <user>username</user>
    <password>password</password>
  </jdbc>
  <generator>
    <database>
      <inputSchema>myschema</inputSchema>
      <customTypes>
        <customType>
          <name>LocalDate</name>
          <type>java.time.LocalDate</type>
          <converter>my.package.LocalDateConverter</converter>
        </customType>
        <customType>
          <name>LocalDateTime</name>
          <type>java.time.LocalDateTime</type>
          <converter>my.package.LocalDateTimeConverter</converter>
        </customType>
      </customTypes>
      <forcedTypes>
        <forcedType>
          <name>LocalDate</name>
          <types>date</types>
        </forcedType>
        <forcedType>
          <name>LocalDateTime</name>
          <types>datetime</types>
        </forcedType>
      </forcedTypes>
    </database>
    <generate />
    <target>
      <packageName>my.package</packageName>
      <directory>src/main/java</directory>
    </target>
  </generator>
</configuration>


There are some enum columns present in the schema completely unrelated to 
LocalDate or LocalDateTime types and I would expect them to be generated. 
However, with the <forcedType> tags the enums are not generated.

I was looking at jOOQ sources, and found lines 292-294 at org/jooq/util/
mysql/ <goog_1595004041>

*MySQLDatabase.java 
<https://github.com/jOOQ/jOOQ/blob/246a7261ed2780b2395da3c79fa49c51fa9b3c97/jOOQ-meta/src/main/java/org/jooq/util/mysql/MySQLDatabase.java>*These
 
lines should filter out enums that match some of the forcedTypes, however, 
when getConfiguredForcedType is called like this, regex in <types> tag is 
never considered as filter. So when there is <forcedType> without 
<expression> filter, the return of getConfiguredForcedType is never null 
and all enums are always filtered out. It would be necessary to add 
DataTypeDefinition as second argument to make it work.

Workaround would be not to use <types> filter and always use <expression>. 
There is also unaswered stackoverflow question regarding this bug - 
http://stackoverflow.com/questions/30260953/how-to-make-jooq-generate-both-enum-types-and-custom-types


Could you please evaluate this problem and possibly suggest a fix?

Regards and thanks.

-- 
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.

Reply via email to