Potential bug introduced in 3.12.x in AbstractField.cast(Class)

27 views
Skip to first unread message

jamesl...@gmail.com

unread,
Jan 9, 2020, 2:15:25 PM1/9/20
to jOOQ User Group
I started to migrate a project today from 3.11.11 to 3.12.3 and got some test failures. I think I tracked it down to this check no longer existing in 3.12.3 Specifically we have a DefaultRecordListener that sets our standard created_at and modified_at fields on a record. This snippet kind of shows what we are doing:

private void setFieldToNow(final Record record, final String fieldName) {
   
final Field<?> field = record.field(fieldName);
   
if (null != field) {
       
final Field<DateTime> fieldToSet = field.cast(DateTime.class);
        record
.setValue(fieldToSet, getNowUTC());
   
}
}

In version 3.12.3, when it calls record.setValue it returns the following error:

java.lang.IllegalArgumentException: Field (cast("public"."person"."modified_at" as timestamp)) is not contained in Row

When I switch it back to 3.11.11, I do not receive this error and my tests pass.

I'm pretty sure I can just workaround this issue by doing the following, but I wanted you to be aware.

final Field<DateTime> fieldToSet = (Field<DateTime>)field;
record
.setValue(fieldToSet, getNowUTC());

Thanks,
James Lorenzen

David Karlsen

unread,
Jan 9, 2020, 5:04:01 PM1/9/20
to jooq...@googlegroups.com
I think that's the same issue I encountered - see this post: https://groups.google.com/d/msg/jooq-user/ow72fRmHXHg/VlJ7aBXqAQAJ

--
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 jooq-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/70b7884a-c60a-4160-acbf-e114c09b1be2%40googlegroups.com.


--

Lukas Eder

unread,
Jan 14, 2020, 5:10:57 AM1/14/20
to jOOQ User Group
Thanks for your link, David. I confirm that seems to be the same issue.

The Field.cast() expression should not have worked prior to 3.12. The fact that it did was an "accident".

- Lukas

Reply all
Reply to author
Forward
0 new messages