Yes, I have replicated this, will get it fixed and released ASAP.
-Brian
>
> Best regards
> Henrik
Okay, so right now it is working "as expected" but the behavior is not
good. Unless overridden the sql object api falls through to
Statement#setObject(...) which provides vendor-specific behavior based
on whatever the vendor feels like doing. It makes sense to keep the
default behavior as setObject(), it is easy to remember, but db
vendors don't always do smart things. We have a few options:
a) detect if it is an enum and bind it as a string in ObjectArgument
b) Add an enum binder which can be registered on the sql object or
method which will detect enums and bind them appropriately.
c) Provide a @ReasonablySmartBindingBehavior type annotation (example
name) which handles all these types of special cases and is must be
explicitly used.
I am actually torn on the right approach to this and would like
feedback. I suspect Statement#setObject(...) with an enum is probably
effectively broken on all drivers, so better default behavior from
JDBI makes sense, but as drivers pick up better behavior, I don't want
to create confusion around hard to find special cases when users don't
get the behavior they expect.
What do folks think?
>
> -Brian
>
>>
>> Best regards
>> Henrik
I don't know which way to lean, but thought I will share one
additional aspect: enums have 'name()' and 'toString()', which may or
may not do the same thing, so there's also choice between these two.
By default I think they return the same, so using toString() may make
most sense, as it can be overridden.
I think that this choice might make most sense as long as it is
overridable: JDBC drivers do quite a bit of implicit casting anyway,
so it would seem closest to "just works" goal.
-+ Tatu +-
--