New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad Results returned from plain SQL "select *" queries, if several selected columns share the same name #1860

Closed
lukaseder opened this Issue Oct 7, 2012 · 0 comments

Comments

Projects
None yet
1 participant
@lukaseder
Member

lukaseder commented Oct 7, 2012

This was recently reported in this thread here:
https://groups.google.com/d/topic/jooq-user/dKgzmsibazM/discussion

It can be reproduced as such:

Java code using DSL API:

jooq.testing.tables.Node n1 = NODE.as("n1");
jooq.testing.tables.Node n2 = NODE.as("n2");
db.select().from(n1).leftOuterJoin(n2).on(n1.ID.eq(n2.NEXT_ID))


Results:

20121004 00:32:58.086 [main] DEBUG - Executing query          : select "n1"."ID", "n1"."NAME", "n1"."NEXT_ID", "n1"."PREV_ID", "n2"."ID", "n2"."NAME", "n2"."NEXT_ID", "n2"."PREV_ID" from "TESTING"."NODE" as "n1" left outer join "TESTING"."NODE" as "n2" on "n1"."ID" = "n2"."NEXT_ID"
20121004 00:32:58.089 [main] DEBUG - Query executed           : Total: 4.992ms
20121004 00:32:58.233 [main] DEBUG - Fetched result           : +----+----+-------+-------+------+------+-------+-------+
20121004 00:32:58.234 [main] DEBUG -                          : |  ID|NAME|NEXT_ID|PREV_ID|    ID|NAME  |NEXT_ID|PREV_ID|
20121004 00:32:58.234 [main] DEBUG -                          : +----+----+-------+-------+------+------+-------+-------+
20121004 00:32:58.234 [main] DEBUG -                          : |   1|A   | {null}| {null}|     4|D     |      1| {null}|
20121004 00:32:58.234 [main] DEBUG -                          : |   1|A   | {null}| {null}|     5|E     |      1| {null}|
20121004 00:32:58.235 [main] DEBUG -                          : |   2|B   | {null}| {null}|{null}|{null}| {null}| {null}|
20121004 00:32:58.235 [main] DEBUG -                          : |   3|C   | {null}| {null}|{null}|{null}| {null}| {null}|
20121004 00:32:58.235 [main] DEBUG -                          : |   4|D   |      1| {null}|{null}|{null}| {null}| {null}|
20121004 00:32:58.235 [main] DEBUG -                          : +----+----+-------+-------+------+------+-------+-------+
20121004 00:32:58.235 [main] DEBUG -                          : |...1 record(s) truncated...
20121004 00:32:58.236 [main] DEBUG - Finishing                : Total: 152.295ms, +147.302ms


Java code using SQL:

db.resultQuery("select * from node n1 left join node n2 on n1.id=n2.next_id");

Results:

20121003 23:52:23.254 [main] DEBUG - Executing query          : select * from node n1 left join node n2 on n1.id=n2.next_id;
20121003 23:52:23.257 [main] DEBUG - Query executed           : Total: 3.246ms
20121003 23:52:23.509 [main] DEBUG - Fetched result           : +------+------+-------+-------+------+------+-------+-------+
20121003 23:52:23.509 [main] DEBUG -                          : |    ID|NAME  |NEXT_ID|PREV_ID|    ID|NAME  |NEXT_ID|PREV_ID|
20121003 23:52:23.509 [main] DEBUG -                          : +------+------+-------+-------+------+------+-------+-------+
20121003 23:52:23.510 [main] DEBUG -                          : |     4|D     |      1| {null}|     4|D     |      1| {null}|
20121003 23:52:23.510 [main] DEBUG -                          : |     5|E     |      1| {null}|     5|E     |      1| {null}|
20121003 23:52:23.510 [main] DEBUG -                          : |{null}|{null}| {null}| {null}|{null}|{null}| {null}| {null}|
20121003 23:52:23.510 [main] DEBUG -                          : |{null}|{null}| {null}| {null}|{null}|{null}| {null}| {null}|
20121003 23:52:23.511 [main] DEBUG -                          : |{null}|{null}| {null}| {null}|{null}|{null}| {null}| {null}|
20121003 23:52:23.511 [main] DEBUG -                          : +------+------+-------+-------+------+------+-------+-------+
20121003 23:52:23.511 [main] DEBUG -                          : |...1 record(s) truncated...
20121003 23:52:23.511 [main] DEBUG - Finishing                : Total: 257.586ms, +254.34ms

lukaseder added a commit that referenced this issue Oct 7, 2012

[#1860] Bad Results returned from plain SQL "select *" queries, if
several selected columns share the same name - Added test case

lukaseder added a commit that referenced this issue Oct 21, 2012

[#1860] Bad Results returned from plain SQL "select *" queries, if
several selected columns share the same name
[#1720] Improve performance by using Record.getValue(int) instead
of Record.getValue(Field) internally, where more than one value is
retrieved from a record

@lukaseder lukaseder closed this Oct 21, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment