Hi

I had a misunderstaning how the API works. I thought that if you get field by position and then get the value with that field you will get value of that position. But anyway, with your proposed change results are now fine also when using embeded SQL! Thank you!

Cheers,

JK

On 28.10.2012 23:29, Lukas Eder wrote:
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


Reply via email to