@@ -212,16 +212,19 @@ export function columnReach(manifestPath: string, model: string, column: string,
212212 const tracked = new Map < string , Set < string > > ( [ [ targetId , new Set ( [ column0 ] ) ] ] )
213213 // The same columns with their case kept: consulted only where a parent's names differ by case alone.
214214 // The target's own spelling comes from the manifest: the caller's when documented as typed, else
215- // every spelling matching ignoring case, else the caller's.
215+ // the one spelling matching ignoring case, else the caller's. Two documented spellings that only
216+ // case tells apart, neither typed as given, leave the column unsettled: no reader of either is certain.
216217 const spellings = Object . entries < any > ( target . columns ?? { } ) . map ( ( [ key , col ] ) => String ( col ?. name ?? key ) )
217- const spelled = spellings . includes ( column ) ? [ column ] : spellings . filter ( ( name ) => name . toLowerCase ( ) === column0 )
218- const trackedExact = new Map < string , Set < string > > ( [ [ targetId , new Set ( spelled . length > 0 ? spelled : [ column ] ) ] ] )
218+ const matches = spellings . filter ( ( name ) => name . toLowerCase ( ) === column0 )
219+ const unsettled = ! spellings . includes ( column ) && matches . length > 1
220+ const spelled = spellings . includes ( column ) ? [ column ] : unsettled ? [ ] : matches . length > 0 ? matches : [ column ]
221+ const trackedExact = new Map < string , Set < string > > ( [ [ targetId , new Set ( spelled ) ] ] )
219222 const carries = ( parent : string , source : { column : string ; exact : string } ) =>
220223 ! ! tracked . get ( parent ) ?. has ( source . column ) &&
221224 ( ! caseCollides ( lookup ( parent ) , source . column ) || ! ! trackedExact . get ( parent ) ?. has ( source . exact ) )
222225 // Nodes whose outputs are unknown (untraced, or read through an ambiguous name): their children
223226 // may read the column too. A node that only filters on it was traced and carries nothing on.
224- const unsure = new Set < string > ( )
227+ const unsure = new Set < string > ( unsettled ? [ targetId ] : [ ] )
225228 const reached : ColumnReachModel [ ] = [ ]
226229 const uncertain : ColumnReachUnsure [ ] = [ ]
227230 const untraced : ColumnReachUnsure [ ] = [ ]
0 commit comments