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

Add code generation flag to treat MySQL TINYINT(1) as BOOLEAN #7719

Closed
lukaseder opened this issue Aug 6, 2018 · 4 comments

Comments

@lukaseder
Copy link
Member

commented Aug 6, 2018

In MySQL, TINYINT(1), by convention, is treated as a BOOLEAN type. We should introduce a code generation flag to expose this behaviour.

Instead of focusing only on TINYINT(1), we'll add a flag that allows for replacing INFORMATION_SCHEMA.COLUMNS.DATA_TYPE by INFORMATION_SCHEMA.COLUMNS.COLUMN_TYPE for integer types:

  • tinyint
  • smallint
  • mediumint
  • int
  • bigint

We'll add a new flag <integerDisplayWidths>true</integerDisplayWidths> which defaults to true and can be deactivated to get the old behaviour of jOOQ 3.11.

With the above flag in place, it's now possible to force TINYINT(1) and similar types to BOOLEAN:

<forcedType>
  <name>BOOLEAN</name>
  <includeTypes>(?i:(TINY|SMALL|MEDIUM|BIG)?INT(UNSIGNED)?\(1\))</includeTypes>
</forcedType>

See also:
https://stackoverflow.com/q/51694152/521799

@pareklund

This comment has been minimized.

Copy link

commented Oct 31, 2018

Until 3.12.0 is released, is there a workaround other than manually map from Byte in the POJO class to boolean in my domain class?

@lukaseder

This comment has been minimized.

Copy link
Member Author

commented Oct 31, 2018

@pareklund Sure! You could use programmatic code generator configuration to generate the regular expression that matches all the TINYINT(1) columns in your schema:
https://www.jooq.org/doc/latest/manual/code-generation/codegen-programmatic

Alternatively, you map directly from the jOOQ record to your domain class using jOOQ's Record.into(DomainClass.class) method. It can translate between numeric and boolean types.

@pareklund

This comment has been minimized.

Copy link

commented Oct 31, 2018

Ok, thanks for the quick reply!

@lukaseder lukaseder changed the title Add code generation flag to treat TINYINT(1) as BOOLEAN Add code generation flag to treat MySQL TINYINT(1) as BOOLEAN Mar 7, 2019
@lukaseder lukaseder added the R: Fixed label Mar 7, 2019
@lukaseder lukaseder closed this Mar 7, 2019
@lukaseder

This comment has been minimized.

Copy link
Member Author

commented Sep 27, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.