Hi Ben, Sure, the regex is applied on a transformed version of the data type / precision / scale information, which might not exactly match the one given in the dictionary views...
The relevant logic is in: org.jooq.util.AbstractDatabase.getConfiguredForcedType(Definition definition, DataTypeDefinition definedType) Hope this helps, Lukas 2015-12-08 17:57 GMT+01:00 Ben Hood <[email protected]>: > Hi Lukas, > > Unfortunately the whitespace (i.e. <types>NUMBER(19, 0)</types>) had no > effect. > > Do you know whereabouts the results from > "SYS"."ALL_TAB_COLS"."DATA_TYPE" and > "SYS"."ALL_TAB_COLS"."DATA_PRECISION" are merged together in the code > to form a grep-able type match? If you give me a hint, I might be able > to set a break point to discover how this type information is being > post-processed with my particular schema. > > Cheers, > > Ben > > On Mon, Dec 7, 2015 at 7:47 AM, Lukas Eder <[email protected]> wrote: > > Hi Ben, > > > > If you use <types>NUMBER</types>, then all number types will be mapped to > > BIGINT - that's probably not what you want - specifically if you do have > > numbers that are best mapped by BigDecimal. > > I will need to look into this to see what's going on. You should be able > to > > match only on a specific precision / scale. > > > > Just to be sure, have you tried <types>NUMBER(19, 0)</types> (with a > > whitespace before the 0)? > > > > Best Regards, > > Lukas > > > > > > 2015-12-04 14:53 GMT+01:00 Ben Hood <[email protected]>: > >> > >> Hi Lukas, > >> > >> Many thanks for the heads up. > >> > >> This seems to do the trick, if I increase the scope of the match > >> expression to include "NUMBER". > >> > >> This is the DDL that JOOQ has introspected (as logged by the generator): > >> > >> [DEBUG] Fetched result : > >> > >> > +---------------+---------+-----------+--------------+----------+--------+--------------------------------------+-----------+---------+--------+ > >> [DEBUG] : > >> > >> > |DATA_TYPE_OWNER|DATA_TYPE|char_length|DATA_PRECISION|DATA_SCALE|NULLABLE|DATA_DEFAULT > >> |COLUMN_NAME|COLUMN_ID|COMMENTS| > >> [DEBUG] : > >> > >> > +---------------+---------+-----------+--------------+----------+--------+--------------------------------------+-----------+---------+--------+ > >> [DEBUG] : |{null} |NUMBER | > >> 0| 19| 0|N > >> |"SUBSCRIPTIONS"."ISEQ$$_92197".nextval|ID | 1|{null} > >> | > >> [DEBUG] : |{null} |VARCHAR2 | > >> 100| {null}| {null}|Y |{null} > >> |NAME | 2|{null} | > >> [DEBUG] : > >> > >> > +---------------+---------+-----------+--------------+----------+--------+--------------------------------------+-----------+---------+--------+ > >> > >> So if I use the expression > >> > >> <types>NUMBER(19)|NUMBER(19,0)</types> > >> > >> I get the following output from the generator: > >> > >> $ mvn clean compile -X | grep 'TENANTS\.ID' > >> [DEBUG] Adding primary key : SYS_C0010277 ( > SUBSCRIPTIONS.TENANTS.ID) > >> [DEBUG] Type mapping : SUBSCRIPTIONS.TENANTS.ID with type > >> NUMBER > >> > >> and the type is mapping to the default, BigInteger. > >> > >> If I expand the matcher thusly > >> > >> <types>NUMBER</types> > >> > >> The forced type takes effect: > >> > >> $ mvn clean compile -X | grep 'TENANTS\.ID' > >> [DEBUG] Adding primary key : SYS_C0010277 ( > SUBSCRIPTIONS.TENANTS.ID) > >> [DEBUG] Type mapping : SUBSCRIPTIONS.TENANTS.ID with type > >> NUMBER > >> [INFO] Forcing type : SUBSCRIPTIONS.TENANTS.ID with type > >> NUMBER into BIGINT > >> > >> Does the matcher maybe need to be sensitive of the precision and scale? > >> > >> Cheers, > >> > >> Ben > >> > >> > >> On Fri, Dec 4, 2015 at 7:58 AM, Lukas Eder <[email protected]> > wrote: > >> > The most straightforward way would be to use data type rewriting: > >> > > http://www.jooq.org/doc/latest/manual/code-generation/data-type-rewrites > >> > > >> > <forcedType> > >> > <!-- Specify any data type from org.jooq.impl.SQLDataType --> > >> > <name>BOOLEAN</name> > >> > > >> > <!-- Add a Java regular expression matching fully-qualified > >> > columns. > >> > Use the pipe to separate several expressions. > >> > > >> > If provided, both "expressions" and "types" must match. --> > >> > <expression>.*\.IS_VALID</expression> > >> > > >> > <!-- Add a Java regular expression matching data types to be > >> > forced to > >> > have this type. > >> > > >> > Data types may be reported by your database as: > >> > - NUMBER > >> > - NUMBER(5) > >> > - NUMBER(5, 2) > >> > - any other form. > >> > > >> > It is thus recommended to use defensive regexes for types. > >> > > >> > If provided, both "expressions" and "types" must match. --> > >> > <types>.*</types> > >> > </forcedType> > >> > > >> > > >> > Or, in your case: > >> > > >> > <forcedType> > >> > <name>BIGINT</name> > >> > <expression>.*</expression> > >> > <types>NUMBER(19)|NUMBER(19,0)</types> > >> > </forcedType> > >> > > >> > > >> > I've put both versions, with or without scale - I'm not sure right now > >> > which > >> > one will work. > >> > > >> > Let me know if this works for you. > >> > > >> > -- > >> > 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. > >> > >> -- > >> 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. > > > > > > -- > > 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. > > -- > 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. > -- 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.
