Here is my Database definition...
// Create the basic database
Database database = new Database()
.withName("org.jooq.util.mariadb.MariaDBDatabase")
.withIncludeExcludeColumns(true)
.withIncludes(".*")
.withExcludes(excludes)
.withInputSchema("")
.withUnsignedTypes(false)
.withDateAsTimestamp(true)
// Force TINYINT to INTEGER
.withForcedTypes(new ForcedType()
.withName("INTEGER")
.withTypes("TINYINT"))
// Force SMALLINT to INTEGER
.withForcedTypes(new ForcedType()
.withName("INTEGER")
.withTypes("SMALLINT"))
// This is usually done with a for loop of all my custom types, but
I've added the problem one specifically
// Register the custom converter to the new type
.withCustomTypes(new CustomType()
.withName("krDatabase.customTypes.dbOcs.Enum_TestType.TestType")
.withConverter("krDatabase.customTypes.dbOcs.Enum_TestType.TestTypeConverter"))
// Force specified columns to use new type
.withForcedTypes(new ForcedType()
.withName("krDatabase.customTypes.dbOcs.Enum_TestType.TestType")
.withExpression("db\.table1\.col1|db\.table2\.col2"))
This is my custom type...
import org.jooq.Converter;
import krDatabase.customTypes._Custom_Types;
public class Enum_TestType extends _Custom_Types<Enum_TestType.TestType,
Enum_TestType.TestTypeConverter> {
public static enum TestType {
FIRST (1, "XX"),
SECOND (2, "YY"),
THIRD (3, "ZZ");
private int id;
private String name;
private TestType(int id, String name) {
this.id = id;
this.name = name;
}
public static TestType getEnum(Integer x) {
if (x == null) {
return null;
}
for (TestType type : TestType.values()) {
if (x.intValue() == type.id) {
return type;
}
}
return null;
}
public String getName(){
return name;
}
}
public static class TestTypeConverter implements Converter<Integer,
TestType> {
private static final long serialVersionUID = 1L;
@Override
public TestType from(Integer x) {
if (x == null){
return null;
}
return TestType.getEnum(x);
}
@Override
public Class<Integer> fromType() {
return Integer.class;
}
@Override
public Integer to(TestType x) {
if (x == null) {
return null;
}
return x.id;
}
@Override
public Class<TestType> toType() {
return TestType.class;
}
}
public Enum_TestType() {
super(TestType.class, TestTypeConverter.class);
columns.add("db\\.table1\\.col1");
columns.add("db\\.table2\\.col2");
}
}
If the columns in MYSQL are defined as INTEGER, then this works, if as
TINYINT, then it fails. I believe only the first forcedType is being
picked up (TINYINT to INTEGER)
On Wednesday, 1 February 2017 03:20:34 UTC-5, Lukas Eder wrote:
>
> Thank you very much for reporting, Anthony.
>
> Would you mind showing also:
>
> - The DDL of your table
> - The XML configuration of your code generator
>
> It's probably easier to track down the issue with actual code than a
> description of code...
>
> Thanks,
> Lukas
>
> 2017-02-01 0:23 GMT+01:00 Anthony Calce <[email protected] <javascript:>
> >:
>
>> Hello, I have found the following bug (MariaDB):
>>
>> - I am forcing type TINYINT to INTEGER
>> - If I do a customType and forceType on a column (which is TINYINT),
>> the generator doesn't pick up the converter correctly, and this column is
>> typed as INTEGER (as per the type forcing rule).
>> - I have tried setting my converter's type to Byte, Short, and
>> Integer, and nothing helps.
>>
>> This isn't my only column I'm custom typing (so I know I'm doing it
>> right). It's just the only column with 2 force-type rules. Any ideas on
>> how to solve this? I can just change the column's type back to INTEGER for
>> now (this eats up 4x more data though)
>>
>> --
>> 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] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
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.