@@ -328,8 +328,6 @@ func prepMappedControlQuery(ctx context.Context, refCode string, framework *stri
328328 return nil , err
329329 }
330330
331- fullWhere := []predicate.MappedControl {}
332-
333331 // controls have no parent control, whereas subcontrols do
334332 if parentControlID == nil {
335333 controlWhere := []predicate.Control {
@@ -346,7 +344,7 @@ func prepMappedControlQuery(ctx context.Context, refCode string, framework *stri
346344 controlWhere = append (controlWhere , control .ReferenceFramework (* framework ))
347345 }
348346
349- fullWhere = []predicate.MappedControl {
347+ return []predicate.MappedControl {
350348 mappedcontrol .Or (
351349 mappedcontrol .HasToControlsWith (
352350 controlWhere ... ,
@@ -355,29 +353,28 @@ func prepMappedControlQuery(ctx context.Context, refCode string, framework *stri
355353 controlWhere ... ,
356354 ),
357355 ),
358- }
359- } else {
360- subControlWhere := []predicate.Subcontrol {
361- subcontrol .RefCode (refCode ),
362- subcontrol .ControlID (* parentControlID ),
363- subcontrol .Or (
364- subcontrol .SystemOwned (true ),
365- subcontrol .OwnerIDIn (orgIDs ... ),
366- ),
367- }
368- fullWhere = []predicate.MappedControl {
369- mappedcontrol .Or (
370- mappedcontrol .HasToSubcontrolsWith (
371- subControlWhere ... ,
372- ),
373- mappedcontrol .HasToSubcontrolsWith (
374- subControlWhere ... ,
375- ),
376- ),
377- }
356+ }, nil
378357 }
379358
380- return fullWhere , nil
359+ subControlWhere := []predicate.Subcontrol {
360+ subcontrol .RefCode (refCode ),
361+ subcontrol .ControlID (* parentControlID ),
362+ subcontrol .Or (
363+ subcontrol .SystemOwned (true ),
364+ subcontrol .OwnerIDIn (orgIDs ... ),
365+ ),
366+ }
367+
368+ return []predicate.MappedControl {
369+ mappedcontrol .Or (
370+ mappedcontrol .HasToSubcontrolsWith (
371+ subControlWhere ... ,
372+ ),
373+ mappedcontrol .HasToSubcontrolsWith (
374+ subControlWhere ... ,
375+ ),
376+ ),
377+ }, nil
381378}
382379
383380// getMappedControlInfo returns all the control information for controls mapped to a ref code, it returns a map
0 commit comments