Generated record key()-method not returning the primary key

19 views
Skip to first unread message

jklingsporn

unread,
Nov 7, 2016, 4:04:34 AM11/7/16
to jOOQ User Group
Hi,
I just noticed that the key()-method in my generated record does not return the actual primary key of that table but only a key type of Record1 (and not Record3). 


I'm using jOOQ 3.8.6 and MySQL 5.6.16.
Here is the table schema:

CREATE TABLE `config_preset_track_part` (
 `trackId` int(10) NOT NULL,
 `configId` int(10) NOT NULL,
 `trackPartIndex` int(10) NOT NULL,
 `checkPointIndex` int(10) NOT NULL,
 PRIMARY KEY (`trackId`,`trackPartIndex`,`checkPointIndex`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;


Edit: It works fine when I define the primary key columns in order, so this


CREATE TABLE
`config_preset_track_part` (
`trackId` int(10) NOT NULL,
`trackPartIndex` int(10) NOT NULL,
`checkPointIndex` int(10) NOT NULL,
`configId` int(10) NOT NULL,
 PRIMARY KEY (`trackId`,`trackPartIndex`,`checkPointIndex`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

works.

Lukas Eder

unread,
Nov 7, 2016, 8:18:07 AM11/7/16
to jooq...@googlegroups.com
Thank you very much for reporting this, Jens. I have registered an issue for this:

Unfortunately, I cannot yet seem to reproduce this on MySQL 5.7. Could you perhaps test on your side if this query yields the correct columns?

SELECT *
FROM information_schema.statistics
WHERE index_name = 'PRIMARY'
AND table_name = 'config_preset_track_part'
ORDER BY seq_in_index

That's a simplified version of the one jOOQ runs to fetch primary key columns...

Cheers,
Lukas

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jklingsporn

unread,
Nov 7, 2016, 9:40:39 AM11/7/16
to jOOQ User Group
# TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, NON_UNIQUE, INDEX_SCHEMA, INDEX_NAME, SEQ_IN_INDEX, COLUMN_NAME, COLLATION, CARDINALITY, SUB_PART, PACKED, NULLABLE, INDEX_TYPE, COMMENT, INDEX_COMMENT
def, test, config_preset_track_part, 0, test, PRIMARY, 1, trackId, A, 1, , , , BTREE, , 
def, test, config_preset_track_part, 0, test, PRIMARY, 2, trackPartIndex, A, 1, , , , BTREE, , 
def, test, config_preset_track_part, 0, test, PRIMARY, 3, checkPointIndex, A, 1, , , , BTREE, , 
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.

Lukas Eder

unread,
Nov 7, 2016, 9:50:26 AM11/7/16
to jooq...@googlegroups.com
Hi Jens,

Hmm, interesting, that looks correct to me then. I'm afraid I cannot be of any further help right now as I cannot reproduce this and the data produced by your MySQL instance also looks correct.

If you're willing to debug this, there are two interesting pointers where stuff might go wrong:

1. At the collection of primary key columns:

2. Where the code is generated:

Let me know if you need any additional info.
Lukas

To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+unsubscribe@googlegroups.com.

jklingsporn

unread,
Nov 7, 2016, 10:06:13 AM11/7/16
to jOOQ User Group
One additional note: I have two databases containing the same schema (one for integration tests, the other for development). Could that be an issue?

Lukas Eder

unread,
Nov 7, 2016, 10:19:34 AM11/7/16
to jooq...@googlegroups.com
It shouldn't be an issue on the jOOQ side, although there may always be hidden bugs. In this case, however, I haven't seen that table in any other schema. The query I've sent you and whose results you posted checked only for the table name, not the schema as well:

SELECT *
FROM information_schema.statistics
WHERE index_name = 'PRIMARY'
AND table_name = 'config_preset_track_part'
ORDER BY seq_in_index

So, if you really have this table twice in your database, it should have appeared twice in the results as well, no?

To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+unsubscribe@googlegroups.com.

jklingsporn

unread,
Nov 7, 2016, 11:32:09 AM11/7/16
to jOOQ User Group
Yes, but I was smart and added a 

AND table_schema = 'test'

to the query ^^

Lukas Eder

unread,
Nov 18, 2016, 6:19:00 AM11/18/16
to jooq...@googlegroups.com
Hi Jens,

Sorry, I overlooked that this is still an open issue. I cannot reproduce this problem yet. Do you have any additional heads-up for me with respect to what could have gone wrong during the code generation, or what might be causing this? Do you get the correct key columns from my original query?

Cheers,
Lukas

To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages