mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 13:10:44 +00:00
CTLE-421: fixed bug caught by tests
This commit is contained in:
@ -34,6 +34,7 @@ import com.kingsrook.qqq.backend.core.model.actions.tables.insert.InsertOutput;
|
|||||||
import com.kingsrook.qqq.backend.core.model.actions.tables.update.UpdateInput;
|
import com.kingsrook.qqq.backend.core.model.actions.tables.update.UpdateInput;
|
||||||
import com.kingsrook.qqq.backend.core.model.data.QRecord;
|
import com.kingsrook.qqq.backend.core.model.data.QRecord;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
|
import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
|
||||||
|
import com.kingsrook.qqq.backend.core.utils.CollectionUtils;
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -131,12 +132,15 @@ public abstract class ChildInserterPostInsertCustomizer extends AbstractPostInse
|
|||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
List<QRecord> recordsToUpdate = new ArrayList<>();
|
List<QRecord> recordsToUpdate = new ArrayList<>();
|
||||||
for(QRecord record : records)
|
for(QRecord record : records)
|
||||||
|
{
|
||||||
|
Serializable primaryKey = record.getValue(table.getPrimaryKeyField());
|
||||||
|
if(record.getValue(getForeignKeyFieldName()) == null)
|
||||||
{
|
{
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// get the corresponding child record, if it has any errors, set that as a warning in the parent //
|
// get the corresponding child record, if it has any errors, set that as a warning in the parent //
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
QRecord childRecord = insertedRecordIterator.next();
|
QRecord childRecord = insertedRecordIterator.next();
|
||||||
if(childRecord.getErrors() != null)
|
if(CollectionUtils.nullSafeHasContents(childRecord.getErrors()))
|
||||||
{
|
{
|
||||||
for(String childWarning : childRecord.getErrors())
|
for(String childWarning : childRecord.getErrors())
|
||||||
{
|
{
|
||||||
@ -146,10 +150,7 @@ public abstract class ChildInserterPostInsertCustomizer extends AbstractPostInse
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Serializable primaryKey = record.getValue(table.getPrimaryKeyField());
|
Serializable foreignKey = childRecord.getValue(childTable.getPrimaryKeyField());
|
||||||
if(record.getValue(getForeignKeyFieldName()) == null)
|
|
||||||
{
|
|
||||||
Serializable foreignKey = insertedRecordIterator.next().getValue(childTable.getPrimaryKeyField());
|
|
||||||
recordsToUpdate.add(new QRecord().withValue(table.getPrimaryKeyField(), primaryKey).withValue(getForeignKeyFieldName(), foreignKey));
|
recordsToUpdate.add(new QRecord().withValue(table.getPrimaryKeyField(), primaryKey).withValue(getForeignKeyFieldName(), foreignKey));
|
||||||
record.setValue(getForeignKeyFieldName(), foreignKey);
|
record.setValue(getForeignKeyFieldName(), foreignKey);
|
||||||
rs.add(record);
|
rs.add(record);
|
||||||
|
Reference in New Issue
Block a user