add one_field for corresponding m2o relations of file relation (#13272)

This commit is contained in:
Brainslug
2022-05-14 00:03:51 +02:00
committed by GitHub
parent bc69297ac9
commit 84e17b608c

View File

@@ -1,5 +1,6 @@
import { StateUpdates, State, HelperFunctions } from '../types';
import { set } from 'lodash';
import { setRelatedOneFieldForCorrespondingField } from './m2o';
export function applyChanges(updates: StateUpdates, state: State, helperFn: HelperFunctions) {
const { hasChanged, getCurrent } = helperFn;
@@ -13,6 +14,10 @@ export function applyChanges(updates: StateUpdates, state: State, helperFn: Help
updateRelationField(updates);
}
if (hasChanged('fields.corresponding')) {
setRelatedOneFieldForCorrespondingField(updates);
}
if (hasChanged('field.schema.is_nullable')) {
if (updates.field?.schema?.is_nullable === false && getCurrent('relations.m2o.schema.on_delete') === 'SET NULL') {
set(updates, 'relations.m2o.schema.on_delete', 'NO ACTION');