diff --git a/backend/pkg/database/gorm_common.go b/backend/pkg/database/gorm_common.go index 165b42467..0c6d9ca15 100644 --- a/backend/pkg/database/gorm_common.go +++ b/backend/pkg/database/gorm_common.go @@ -1001,8 +1001,11 @@ func (gr *GormRepository) ListBackgroundJobs(ctx context.Context, queryOptions m var backgroundJobs []models.BackgroundJob query := gr.GormClient.WithContext(ctx). //Group("source_id"). //broken in Postgres. - Where(queryParam).Limit(queryOptions.Limit).Order("locked_time DESC") + Where(queryParam).Order("locked_time DESC") + if queryOptions.Limit > 0 { + query = query.Limit(queryOptions.Limit) + } if queryOptions.Offset > 0 { query = query.Offset(queryOptions.Offset) } diff --git a/backend/pkg/database/gorm_repository_test.go b/backend/pkg/database/gorm_repository_test.go index e8c0ee6eb..deb177bab 100644 --- a/backend/pkg/database/gorm_repository_test.go +++ b/backend/pkg/database/gorm_repository_test.go @@ -61,9 +61,9 @@ func (suite *RepositoryTestSuite) BeforeTest(suiteName, testName string) { // AfterTest has a function to be executed right after the test finishes and receives the suite and test names as input func (suite *RepositoryTestSuite) AfterTest(suiteName, testName string) { suite.MockCtrl.Finish() - os.Remove(suite.TestDatabase.Name()) - os.Remove(suite.TestDatabase.Name() + "-shm") - os.Remove(suite.TestDatabase.Name() + "-wal") + //os.Remove(suite.TestDatabase.Name()) + //os.Remove(suite.TestDatabase.Name() + "-shm") + //os.Remove(suite.TestDatabase.Name() + "-wal") } // In order for 'go test' to run this suite, we need to create