Hello,

There's a common misconception among MySQL users that TINYINT(1) is:

- A good hint for the type to have boolean semantics
- An actual type

When you specify TINYINT(1), the type will still be a TINYINT. Observe the
following:

CREATE TABLE t(i TINYINT(1));

INSERT INTO t VALUES (1);
INSERT INTO t VALUES (2);
INSERT INTO t VALUES (10);

SELECT * FROM t;


You'll get:

 i
--
 1
 2
10


That explains why it would be unwise for jOOQ to consider that "length"
information for any type deduction.

The "global" type conversion mechanism that you could use would be to
create your own general-purpose Binding and use that for every dynamically
created column expression (you'd have to know these columns in advance,
though).

Otherwise, you could patch jOOQ's internal MetaDataFieldProvider and put
the desired logic there.

In any case, I think your idea is very interesting. jOOQ should have an SPI
that allows for overriding such default types at runtime. I've created a
feature request for this:
https://github.com/jOOQ/jOOQ/issues/6619

Cheers,
Lukas

2017-09-29 14:31 GMT+02:00 <[email protected]>:

> Since jOOQ does not map TINYINT(1) to java.lang.Boolean by default, is it
> possible to add this mapping programmatically? The solutions I found do not
> fit my case, which is:
> DSL.using( SQLDialect.MYSQL ).fetchOne( resultSet ).intoMap()
>
> The problem is that the fields list is completely dynamic, so I can't set
> proper Bindings or Converters on Field instances. Rather I need this
> setting to be global, attached to some configuration or something.
>
> --
> 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.

Reply via email to