Skip to content

Meta.ddl() ignores data type for sequences #15322

@mgramin

Description

@mgramin

Expected behavior

We expect that Meta.ddl() exports a valid DDL for sequences:

create sequence SAMPSEQUENCE AS BIGINT maxvalue 9223372036854775807

Actual behavior

Meta.ddl() exports broken DDL for that sequences ignoring data type:

create sequence "DB2INST1"."SAMPSEQUENCE" maxvalue 9223372036854775807

Steps to reproduce the problem

Create a bigint typed sequence in DB:

create sequence SAMPSEQUENCE AS BIGINT maxvalue 9223372036854775807;

Run this code:

        Connection conn = DriverManager.getConnection("jdbc:db2://localhost:50000/sample", "db2inst1", "secret_password");
        Configuration configuration = new DefaultConfiguration().set(conn).set(SQLDialect.DB2);
        Meta meta = using(configuration).meta();

        Arrays.stream(meta.filterSchemas(v -> v.getName().equalsIgnoreCase("DB2INST1"))
                        .filterTables(v -> false)
                        .ddl()
                        .queries())
                .map(Object::toString)
                .forEach(System.out::println);

Executing the resulting query against a different database or schema:

create sequence "DB2INST1"."SAMPSEQUENCE" maxvalue 9223372036854775807

leads to the error:

SQL Error [42815]: Invalid specification of an identity column or sequence object "SEQUENCE" "DB2INST1.SAMPSEQUENCE". Reason code = "2".. SQLCODE=-846, SQLSTATE=42815, DRIVER=4.31.10

jOOQ Version

jOOQ Professional Edition 3.18.4

Database product and version

DB2 v11.5.8.0

Java Version

openjdk 17.0.2 2022-01-18

OS Version

Microsoft Windows [Version 10.0.19044.2846]

JDBC driver name and version (include name if unofficial driver)

com.ibm.db2.jcc:db2jcc:db2jcc4

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions