[jOOQ/jOOQ#16782] NullPointerException in MetaImpl when looking up a dropped table from a disabled foreign key in MySQL
This commit is contained in:
parent
0185a3f314
commit
fa62ca56b3
@ -1204,38 +1204,44 @@ final class MetaImpl extends AbstractMeta {
|
||||
: name(defaultString(k.get(1, String.class)))
|
||||
);
|
||||
|
||||
String fkName = k.get(3, String.class);
|
||||
String pkName = k.get(4, String.class);
|
||||
Table<Record> pkTable = (Table<Record>) lookupTable(schema, k.get(2, String.class));
|
||||
TableField<Record, ?>[] pkFields = new TableField[v.size()];
|
||||
TableField<Record, ?>[] fkFields = new TableField[v.size()];
|
||||
|
||||
for (int i = 0; i < v.size(); i++) {
|
||||
Record record = v.get(i);
|
||||
String pkFieldName = record.get(3, String.class);
|
||||
String fkFieldName = record.get(7, String.class);
|
||||
// [#16782] Dangling FK references are possible in some RDBMS that allow for
|
||||
// temporarily deactivating FK checks, e.g. MySQL via SET FOREIGN_KEY_CHECKS=0
|
||||
if (pkTable != null) {
|
||||
String fkName = k.get(3, String.class);
|
||||
String pkName = k.get(4, String.class);
|
||||
|
||||
pkFields[i] = (TableField<Record, ?>) pkTable.field(pkFieldName);
|
||||
fkFields[i] = (TableField<Record, ?>) field(fkFieldName);
|
||||
TableField<Record, ?>[] pkFields = new TableField[v.size()];
|
||||
TableField<Record, ?>[] fkFields = new TableField[v.size()];
|
||||
|
||||
// [#2656] TODO: Find a more generally reusable way to perform case insensitive lookups
|
||||
if (pkFields[i] == null)
|
||||
if ((pkFields[i] = lookup(pkTable, pkFieldName)) == null)
|
||||
return;
|
||||
for (int i = 0; i < v.size(); i++) {
|
||||
Record record = v.get(i);
|
||||
String pkFieldName = record.get(3, String.class);
|
||||
String fkFieldName = record.get(7, String.class);
|
||||
|
||||
if (fkFields[i] == null)
|
||||
if ((fkFields[i] = lookup(this, fkFieldName)) == null)
|
||||
return;
|
||||
pkFields[i] = (TableField<Record, ?>) pkTable.field(pkFieldName);
|
||||
fkFields[i] = (TableField<Record, ?>) field(fkFieldName);
|
||||
|
||||
// [#2656] TODO: Find a more generally reusable way to perform case insensitive lookups
|
||||
if (pkFields[i] == null)
|
||||
if ((pkFields[i] = lookup(pkTable, pkFieldName)) == null)
|
||||
return;
|
||||
|
||||
if (fkFields[i] == null)
|
||||
if ((fkFields[i] = lookup(this, fkFieldName)) == null)
|
||||
return;
|
||||
}
|
||||
|
||||
references.add(new ReferenceImpl<>(
|
||||
this,
|
||||
name(fkName),
|
||||
fkFields,
|
||||
new MetaUniqueKey(pkTable, pkName, pkFields, true), // TODO: Can we know whether it is a PK or UK?
|
||||
pkFields,
|
||||
true
|
||||
));
|
||||
}
|
||||
|
||||
references.add(new ReferenceImpl<>(
|
||||
this,
|
||||
name(fkName),
|
||||
fkFields,
|
||||
new MetaUniqueKey(pkTable, pkName, pkFields, true), // TODO: Can we know whether it is a PK or UK?
|
||||
pkFields,
|
||||
true
|
||||
));
|
||||
});
|
||||
|
||||
return references;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user