Jooq: Generated order of check constraints does not respect Database::getOrderProvider

Created on 14 Jan 2021  路  3Comments  路  Source: jOOQ/jOOQ

Expected behavior

When generating the jOOQ sources with org.jooq.pro-java-8:jooq-codegen-maven (jOOQ 3.14.4 Professional) the check names should be ordered lexicographically in the same order every time.

Actual behavior

When generating the jOOQ sources with org.jooq.pro-java-8:jooq-codegen-maven (jOOQ 3.14.4 Professional) the order of the generated check constraints is random and therefore causes an unnecessary diff when committing, which can be annoying.
image

Steps to reproduce the problem

  • If the problem relates to code generation, please post your code generation configuration
    ```
    org.jooq.pro-java-8
    jooq-codegen-maven
    ${jooq.version}

            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
    
            <dependencies>
                <dependency>
                    <groupId>com.oracle.database.jdbc</groupId>
                    <artifactId>ojdbc8</artifactId>
                    <version>${oracle-ojdbc.version}</version>
                </dependency>
            </dependencies>
    
            <configuration>
                <skip>${skip.jooq.generation}</skip>
    
                <jdbc>
                    <driver>oracle.jdbc.OracleDriver</driver>
                    <url>${jooq-generation-oracle-url}</url>
                    <user>${jooq-generation-oracle-user}</user>
                    <password>${jooq-generation-oracle-password}</password>
                </jdbc>
    
                <generator>
                    <database>
                        <name>org.jooq.meta.oracle.OracleDatabase</name>
                        <includes>.*</includes>
                        <excludes>
                              TABLE_A.*
                            | DUMMY_COLUMN_1
                            | DUMMY_COLUMN_2
                            | DUMMY_COLUMN_3
                            | DUMMY_COLUMN_4
                            | DUMMY_COLUMN_5
                            | DUMMY_COLUMN_6
                        </excludes>
                        <includeExcludeColumns>true</includeExcludeColumns>
                        <logSlowQueriesAfterSeconds>30</logSlowQueriesAfterSeconds>
                        <schemata>
                            <schema>
                                <inputSchema>MDC</inputSchema>
                            </schema>
                            <schema>
                                <inputSchema>MASTER</inputSchema>
                            </schema>
                        </schemata>
                        <forcedTypes>
                            <forcedType>
                                <name>BOOLEAN</name>
                                <includeExpression>.*</includeExpression>
                                <includeTypes>NUMBER\(1,\s*0\)</includeTypes>
                                <nullability>ALL</nullability>
                                <objectType>ALL</objectType>
                            </forcedType>
                            <forcedType>
                                <name>TIMESTAMP</name>
                                <includeExpression>.*</includeExpression>
                                <includeTypes>DATE</includeTypes>
                                <nullability>ALL</nullability>
                                <objectType>ALL</objectType>
                            </forcedType>
                        </forcedTypes>
                    </database>
    
                    <generate>
                        <indexes>true</indexes>
                        <relations>true</relations>
                        <sequenceFlags>true</sequenceFlags>
                        <implicitJoinPathsToOne>true</implicitJoinPathsToOne>
                        <deprecated>false</deprecated>
                        <deprecationOnUnknownTypes>true</deprecationOnUnknownTypes>
                        <generatedAnnotation>true</generatedAnnotation>
                        <records>true</records>
                        <pojos>true</pojos>
                        <pojosEqualsAndHashCode>false</pojosEqualsAndHashCode>
                        <pojosToString>true</pojosToString>
                        <immutablePojos>false</immutablePojos>
                        <serializablePojos>true</serializablePojos>
                        <javadoc>true</javadoc>
                        <fluentSetters>true</fluentSetters>
                        <javaTimeTypes>true</javaTimeTypes>
                    </generate>
    
                    <target>
                        <packageName>com.gknpm.mdcapi.entity</packageName>
                        <directory>src/main/java</directory>
                    </target>
                </generator>
            </configuration>
        </plugin>
    

    ```

Versions

Functionality All Editions Medium Fixed Defect

All 3 comments

Thanks a lot for your report. I can confirm, it seems that the internal Database.orderProvider from jOOQ-meta is not applied to CheckConstraints, meaning you cannot use it as a workaround either. I'll proceed to fixing this immediately.

Note that you can obviously turn off the generation of code for check constraints if you don't need them, e.g. by specifying

<includeCheckConstraints>false</includeCheckConstraints>

Fixed in jOOQ 3.15.0 and 3.14.5 (#11240). Thanks again for your report!

Was this page helpful?
0 / 5 - 0 ratings