Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to alter a table to add a column of Enum/Set type in MySQL. #9698

Closed
susaiarul opened this issue Dec 22, 2019 · 1 comment
Closed

How to alter a table to add a column of Enum/Set type in MySQL. #9698

susaiarul opened this issue Dec 22, 2019 · 1 comment

Comments

@susaiarul
Copy link

How to execute the below statements using jOOQ fluent API.

  1. ALTER TABLE tablename ADD columnname ENUM('value1','value2')

  2. ALTER TABLE tablename ADD columnname SET('value1','value2')

  • jOOQ: 3.12.3
  • Java: 8
  • Database (include vendor): MySQL
  • OS: ubuntu 16.4 LTS
  • JDBC Driver: com.mysql.cj.jdbc.Driver
@lukaseder
Copy link
Member

Thank you very much for your message. We currently do not support the MySQL SET type yet, so there's no easy way to get that working through the jOOQ API. The amount of infrastructure needed to support that type can be seen in this issue: #7382, which hints at this limitation not being easy to work around either, short of simply using plain SQL templating for your ALTER TABLE statement: https://www.jooq.org/doc/latest/manual/sql-building/plain-sql-templating.

The ENUM type can be added by supplying it via SQLDataType.VARCHAR.asEnumDataType(), just like the code generator does. You have to create an Enum that implements org.jooq.EnumType, then you can use that with your ALTER TABLE statement.

@lukaseder lukaseder self-assigned this Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants