Просмотр исходного кода

Don't panic on empty units and units.PrepareFormulars()

Dmitry Yu Okunev лет назад: 6
Родитель
Сommit
fcf26740c6
1 измененных файлов с 8 добавлено и 0 удалено
  1. 8 0
      unit.go

+ 8 - 0
unit.go

@@ -221,6 +221,10 @@ func (u Unit) GetFormulars() Formulars {
 }
 
 func (units Units) PrepareFormulars(activeOnly bool) Units {
+	if len(units) == 0 {
+		return units
+	}
+
 	ids := units.GetUnitIds()
 	nums := units.GetPersNumbers()
 
@@ -230,6 +234,10 @@ func (units Units) PrepareFormulars(activeOnly bool) Units {
 		scope = scope.ActiveOnly()
 	}
 
+	if len(nums) == 0 && len(ids) == 0 {
+		return units
+	}
+
 	if len(nums) > 0 {
 		scope  = scope.Where("PersNumber IN (?) OR OrgDiv IN (?)", nums, ids)
 	} else {