... Note that when using jOOQ APIs to fetch from plain SQL ResultSets,
jOOQ only consumes the ResultSetMetaData.getColumnLabel(int) for every
column. In order to better distinguish columns, I guess jOOQ could
also consume the column's catalog / schema / table names, although I'm
not sure if there is a general rule that would allow for a clean
distinction without corner-cases. E.g. column labels are important
when renaming columns (using aliasing), in case of which table names
usually become irrelevant. Also, functions behave differently from
table columns, etc.

I'm open to ideas

2012/10/28 Lukas Eder <[email protected]>:
> Hello,
>
> Thanks for your detailed test case. The problem here is that there is
> no way to distinguish two fields by name, if they have the exact same
> name (as in org.jooq.Field.getName()). In case you do have such a
> situation, you will have to access values by index. In other words,
> your last test should become:
>
>         {
>             log.debug("Parsing SQL statement");
>             Result<Record> rr = db.fetch("select * from node left
> outer join child_node on node.id=child_node.parent_id where node.name
> = 'B'");
>             List<Field<?>> fieldList = rr.getFields();
>             for ( int r = 0; r < rr.size(); r++ ) {
>                 for ( int f = 0; f < fieldList.size(); f++ ) {
>                     Record record = rr.get(r);
>                     Field field = record.getField(f);
>                     Object value = record.getValue(f); // This line was 
> changed
>                     System.out.println("row = " + r + " " +
> field.getName() + " = " + value);
>                 }
>             }
>         }
>
> If you access fields by name (or field), and there are two fields with
> the same name, jOOQ will return the first value.
>
> Cheers
> Lukas
>
> 2012/10/28 jk3m41l <[email protected]>:
>> On 21.10.2012 18:34, Lukas Eder wrote:
>>>
>>> This issue is fixed on GitHub master. It will be included in the next
>>> 2.6.0-SNAPSHOT version. I'll also merge this fix to 2.5.x and 2.4.x
>>> version branches, soon.
>>>
>>> Cheers
>>> Lukas
>>
>> Hello,
>>
>> Thank you for the update. Unfortunately I still got strange results. In
>> v2.60 debug printouts for "fetched results" seem to be OK also when using
>> SQL, but when getting field values from Result<Record> there are
>> differencies depending on whether you use DSL or SQL. See the attached file.
>>
>> Cheers,
>>
>> J
>>

Reply via email to