Browse Source

Fixed an error on fetching data for all units

Dmitry Yu Okunev 5 years ago
parent
commit
2d432249e6
1 changed files with 7 additions and 1 deletions
  1. 7 1
      unit.go

+ 7 - 1
unit.go

@@ -230,7 +230,13 @@ func (units Units) PrepareFormulars(activeOnly bool) Units {
 		scope = scope.ActiveOnly()
 	}
 
-	formulars, err := scope.Select("PersNumber IN (?) OR OrgDiv IN (?)", nums, ids)
+	if len(nums) > 0 {
+		scope  = scope.Where("PersNumber IN (?) OR OrgDiv IN (?)", nums, ids)
+	} else {
+		scope  = scope.Where("OrgDiv IN (?)", ids)
+	}
+
+	formulars, err := scope.Select()
 	if err != nil && err != sql.ErrNoRows {
 		panic(err)
 	}