@@ -832,6 +832,38 @@ export class ComputedDependencyCollectorService {
832832 } ) . fieldIds . add ( fieldId ) ;
833833 }
834834
835+ const relatedLinkIds = await this . resolveRelatedLinkFieldIds ( startFieldIds ) ;
836+ const fallbackLookupIds = new Set < string > ( ) ;
837+ if ( relatedLinkIds . length ) {
838+ const byTable = await this . findLookupsByLinkIds ( relatedLinkIds ) ;
839+ for ( const [ tid , fset ] of Object . entries ( byTable ) ) {
840+ const group = ( impact [ tid ] ||= {
841+ fieldIds : new Set < string > ( ) ,
842+ recordIds : new Set < string > ( ) ,
843+ } ) ;
844+ fset . forEach ( ( fid ) => {
845+ if ( ! group . fieldIds . has ( fid ) ) {
846+ group . fieldIds . add ( fid ) ;
847+ fallbackLookupIds . add ( fid ) ;
848+ }
849+ } ) ;
850+ }
851+ }
852+
853+ if ( fallbackLookupIds . size ) {
854+ // Legacy compatibility: pre-link reference rows created before lookupOptions.linkFieldId
855+ // existed do not include the link→lookup edge. We need to synthesize those missing
856+ // dependencies so downstream lookups/formulas still recompute.
857+ const extraDeps = await this . collectDependentFieldsByTable ( Array . from ( fallbackLookupIds ) ) ;
858+ for ( const [ tid , fset ] of Object . entries ( extraDeps ) ) {
859+ const group = ( impact [ tid ] ||= {
860+ fieldIds : new Set < string > ( ) ,
861+ recordIds : new Set < string > ( ) ,
862+ } ) ;
863+ fset . forEach ( ( fid ) => group . fieldIds . add ( fid ) ) ;
864+ }
865+ }
866+
835867 if ( ! Object . keys ( impact ) . length ) return { } ;
836868
837869 // 2) Seed recordIds for origin tables with ALL record ids
@@ -1015,9 +1047,31 @@ export class ComputedDependencyCollectorService {
10151047
10161048 // Additionally: include lookup/rollup fields that directly reference any changed link fields
10171049 // (or their symmetric counterparts). This ensures cross-table lookups update when links change.
1050+ const fallbackLookupIds = new Set < string > ( ) ;
10181051 if ( relatedLinkIds . length ) {
10191052 const byTable = await this . findLookupsByLinkIds ( relatedLinkIds ) ;
10201053 for ( const [ tid , fset ] of Object . entries ( byTable ) ) {
1054+ const group = ( impact [ tid ] ||= {
1055+ fieldIds : new Set < string > ( ) ,
1056+ recordIds : new Set < string > ( ) ,
1057+ } ) ;
1058+ fset . forEach ( ( fid ) => {
1059+ if ( ! group . fieldIds . has ( fid ) ) {
1060+ group . fieldIds . add ( fid ) ;
1061+ fallbackLookupIds . add ( fid ) ;
1062+ }
1063+ } ) ;
1064+ }
1065+ }
1066+
1067+ if ( fallbackLookupIds . size ) {
1068+ // Legacy compatibility: some lookup records were created when linkFieldId was
1069+ // not persisted in reference graph, so we back-fill their dependents via traversal.
1070+ const extraDeps = await this . collectDependentFieldsByTable (
1071+ Array . from ( fallbackLookupIds ) ,
1072+ excludeFieldIds
1073+ ) ;
1074+ for ( const [ tid , fset ] of Object . entries ( extraDeps ) ) {
10211075 const group = ( impact [ tid ] ||= {
10221076 fieldIds : new Set < string > ( ) ,
10231077 recordIds : new Set < string > ( ) ,
0 commit comments