I have the following record resulting from a query with a couple of joins:
Now when I try to retrieve a particular column which is not in the result with:
record[REG_MEDEWERKER.ID]
where REG_MEDEWERKER.ID
is generated Kotlin code having the following details:
I expect to get null
. However, the wrong id value (of zkn_zaak.id
) is returned instead.
What am I missing here? Shouldn't jOOQ have enough information (table and field name) to retrieve the correct column from the record?
============ Update =============
From the code it seems this is intended behavior and it is already discussed extensively in e.g. https://github.com/jOOQ/jOOQ/issues/4471, https://github.com/jOOQ/jOOQ/issues/4455, https://github.com/jOOQ/jOOQ/issues/4476 and https://github.com/jOOQ/jOOQ/issues/10266
So this explains a lot.
However, the question remains how I can determine that column REG_MEDEWERKER.ID
is not in the result set...
From the Record.get(Field) Javadoc:
If this record contains a field with the same Field.getName() as the argument field, that value is retrieved.
So the value is retrieved based on the unqualified column name. Only if that column name is ambiguous, qualification is taken into consideration to attempt to disambiguate the column name.
While this may lead to the unexpected result you're experiencing, it has a lot of advantages when working with aliased tables, derived tables, etc.