@@ -764,22 +764,14 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
764764 }
765765
766766 data . data . forEach ( ( item ) => {
767+ item [ col . name ] = targetDataMap [ item [ col . name ] ] ;
767768 if ( col . isArray ?. enabled ) {
768769 if ( item [ col . name ] ?. length ) {
769770 item [ col . name ] = item [ col . name ] . map ( ( i ) => targetDataMap [ i ] ) ;
770771 }
771772 } else {
772773 item [ col . name ] = targetDataMap [ item [ col . name ] ] ;
773774 }
774-
775- if ( ! item [ col . name ] ) {
776- if ( col . foreignResource && col . foreignResource . polymorphicResources ) {
777- const systemResource = col . foreignResource . polymorphicResources . find ( pr => pr . resourceId === null ) ;
778- if ( systemResource ) {
779- item [ col . foreignResource . polymorphicOn ] = systemResource . whenValue ;
780- }
781- }
782- }
783775 } ) ;
784776 } )
785777 ) ;
@@ -1002,7 +994,10 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
1002994
1003995 // for polymorphic foreign resources, we need to find out the value for polymorphicOn column
1004996 for ( const column of resource . columns ) {
1005- if ( column . foreignResource ?. polymorphicOn && record [ column . name ] ) {
997+ if ( column . foreignResource ?. polymorphicOn && record [ column . name ] === null ) {
998+ const systemResource = column . foreignResource . polymorphicResources . find ( pr => pr . resourceId === null ) ;
999+ record [ column . foreignResource . polymorphicOn ] = systemResource . whenValue ;
1000+ } else if ( column . foreignResource ?. polymorphicOn && record [ column . name ] ) {
10061001 const targetResources = { } ;
10071002 const targetConnectors = { } ;
10081003 const targetResourcePkFields = { } ;
@@ -1095,7 +1090,10 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
10951090
10961091 // for polymorphic foreign resources, we need to find out the value for polymorphicOn column
10971092 for ( const column of resource . columns ) {
1098- if ( column . foreignResource ?. polymorphicOn && record [ column . name ] !== undefined ) {
1093+ if ( column . foreignResource ?. polymorphicOn && record [ column . name ] === null ) {
1094+ const systemResource = column . foreignResource . polymorphicResources . find ( pr => pr . resourceId === null ) ;
1095+ record [ column . foreignResource . polymorphicOn ] = systemResource . whenValue ;
1096+ } else if ( column . foreignResource ?. polymorphicOn && record [ column . name ] ) {
10991097 let newPolymorphicOnValue = null ;
11001098 if ( record [ column . name ] ) {
11011099 const targetResources = { } ;
0 commit comments