misc fixes

This commit is contained in:
2023-03-31 16:30:56 -05:00
parent 6fbfbe9db2
commit f79bf85c14
4 changed files with 28 additions and 24 deletions

View File

@ -183,22 +183,15 @@ public class DeleteAction
if(CollectionUtils.nullSafeHasContents(primaryKeyList)) if(CollectionUtils.nullSafeHasContents(primaryKeyList))
{ {
if(CollectionUtils.nullSafeHasContents(deleteInput.getTable().getRecordSecurityLocks())) ////////////////////////////////////////////////////////////////////////////////////
{ // always fetch the records - we'll use them anyway for checking not-exist below //
//////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////
// if the table has any security locks, then we need full entities (to record the keys), not just ids //
////////////////////////////////////////////////////////////////////////////////////////////////////////
QueryInput queryInput = new QueryInput(); QueryInput queryInput = new QueryInput();
queryInput.setTableName(deleteInput.getTableName()); queryInput.setTableName(deleteInput.getTableName());
queryInput.setFilter(new QQueryFilter(new QFilterCriteria(deleteInput.getTable().getPrimaryKeyField(), QCriteriaOperator.IN, primaryKeyList))); queryInput.setFilter(new QQueryFilter(new QFilterCriteria(deleteInput.getTable().getPrimaryKeyField(), QCriteriaOperator.IN, primaryKeyList)));
QueryOutput queryOutput = new QueryAction().execute(queryInput); QueryOutput queryOutput = new QueryAction().execute(queryInput);
recordListForAudit = queryOutput.getRecords(); recordListForAudit = queryOutput.getRecords();
} }
else
{
recordListForAudit = primaryKeyList.stream().map(pk -> new QRecord().withValue(deleteInput.getTable().getPrimaryKeyField(), pk)).toList();
}
}
} }
return (recordListForAudit); return (recordListForAudit);
@ -241,7 +234,9 @@ public class DeleteAction
{ {
for(QRecord record : oldRecordList) for(QRecord record : oldRecordList)
{ {
lookedUpRecords.put(record.getValue(table.getPrimaryKeyField()), record); Serializable primaryKeyValue = record.getValue(table.getPrimaryKeyField());
primaryKeyValue = ValueUtils.getValueAsFieldType(primaryKeyField.getType(), primaryKeyValue);
lookedUpRecords.put(primaryKeyValue, record);
} }
} }
else if(!primaryKeysToLookup.isEmpty()) else if(!primaryKeysToLookup.isEmpty())

View File

@ -81,6 +81,11 @@ public class InsertAction extends AbstractQActionFunction<InsertInput, InsertOut
ActionHelper.validateSession(insertInput); ActionHelper.validateSession(insertInput);
QTableMetaData table = insertInput.getTable(); QTableMetaData table = insertInput.getTable();
if(table == null)
{
throw (new QException("Error: Undefined table: " + insertInput.getTableName()));
}
Optional<AbstractPostInsertCustomizer> postInsertCustomizer = QCodeLoader.getTableCustomizer(AbstractPostInsertCustomizer.class, table, TableCustomizers.POST_INSERT_RECORD.getRole()); Optional<AbstractPostInsertCustomizer> postInsertCustomizer = QCodeLoader.getTableCustomizer(AbstractPostInsertCustomizer.class, table, TableCustomizers.POST_INSERT_RECORD.getRole());
setAutomationStatusField(insertInput); setAutomationStatusField(insertInput);

View File

@ -24,6 +24,7 @@ package com.kingsrook.qqq.backend.core.model.metadata.tables;
import java.util.List; import java.util.List;
import com.kingsrook.qqq.backend.core.model.metadata.layout.QIcon; import com.kingsrook.qqq.backend.core.model.metadata.layout.QIcon;
import com.kingsrook.qqq.backend.core.utils.collections.MutableList;
/******************************************************************************* /*******************************************************************************
@ -63,7 +64,7 @@ public class QFieldSection
this.label = label; this.label = label;
this.icon = icon; this.icon = icon;
this.tier = tier; this.tier = tier;
this.fieldNames = fieldNames; this.fieldNames = new MutableList<>(fieldNames);
} }
@ -76,7 +77,7 @@ public class QFieldSection
this.name = name; this.name = name;
this.icon = icon; this.icon = icon;
this.tier = tier; this.tier = tier;
this.fieldNames = fieldNames; this.fieldNames = new MutableList<>(fieldNames);
} }

View File

@ -649,6 +649,8 @@ public class QJavalinApiHandler
private static void storeApiLog(APILog apiLog) private static void storeApiLog(APILog apiLog)
{ {
try try
{
if(QContext.getQInstance().getTable(APILog.TABLE_NAME) != null)
{ {
InsertInput insertInput = new InsertInput(); InsertInput insertInput = new InsertInput();
insertInput.setTableName(APILog.TABLE_NAME); insertInput.setTableName(APILog.TABLE_NAME);
@ -657,6 +659,7 @@ public class QJavalinApiHandler
insertInput.setRecords(List.of(apiLog.toQRecord())); insertInput.setRecords(List.of(apiLog.toQRecord()));
new InsertAction().executeAsync(insertInput); new InsertAction().executeAsync(insertInput);
} }
}
catch(Exception e) catch(Exception e)
{ {
LOG.warn("Error storing API log", e); LOG.warn("Error storing API log", e);