-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
SQLite "Cannot parse or interpret sql for table" error with both unique columns and foreign key constraints #16675
Comments
Thanks a lot for your report. I can reproduce the problem. Will look into this right away. |
I see, we're interpreting meta DDL SQL table by table, with eager foreign key resolution. But the tables are ordered alphabetically, not in their key order (which can have cycles), so we should delay the foreign key checks, e.g. using |
It doesn't happen without the unique constraint, because that particular code path that interprets all the DDL is only invoked when looking up unique constraints. |
…both unique columns and foreign key constraints
…both unique columns and foreign key constraints
…both unique columns and foreign key constraints
…both unique columns and foreign key constraints
Thanks for looking at this so quickly |
Expected behavior
Code generation maven plugin to run successfully without logging any errors.
Generate unique keys for all UNIQUE columns.
Generate
DAO.fetchOneByX
functions for all UNIQUE columns.Actual behavior
Error logged during code generation:
Unique keys missing for some tables.
Test2Dao.fetchOneByCd
function generated.Steps to reproduce the problem
MCVE
jOOQ-mcve-kotlin-sqlite
directoryThe problem appears to require the combination of columns with UNIQUE constraints and columns with FOREIGN KEY constraints in the same table.
It appears that while processing the unique keys for each table, parsing the foreign keys in the SQL causes an exception which results in aborting processing unique keys. Hence the DAO.fetchOneByX method is not generated.
jOOQ 3.14.16 generates the DAO.fetchOneByX as expected. jOOQ versions 3.15.0 to 3.19.8 omit the DAO.fetchOneByX in some cases.
jOOQ Version
jOOQ 3.19.8
Database product and version
SQLite 3.40.1.0
Java Version
openjdk version "17.0.10" 2024-01-16
JDBC / R2DBC driver name and version (include name if unofficial driver)
org.xerial:sqlite-jdbc:3.40.1.0
The text was updated successfully, but these errors were encountered: