Fix project.active being nullable

Ensure the field defaults to `true`, both in Java and the database. During upgrade, migrate all values that are currently `null` to `true`.

Solidify this change by switching `project.active` from `Boolean` to `boolean`. Adjust logic that previously had to check for `null`.

Fixes #4410

Signed-off-by: nscuro <nscuro@protonmail.com>
This commit is contained in:
nscuro 2024-11-27 21:21:19 +01:00
parent 66c36ba0bb
commit 42b91e887a
No known key found for this signature in database
16 changed files with 157 additions and 65 deletions

View file

@ -182,7 +182,7 @@ final class ProjectQueryManager extends QueryManager implements IQueryManager {
public List<Project> getAllProjects(boolean excludeInactive) {
final Query<Project> query = pm.newQuery(Project.class);
if (excludeInactive) {
query.setFilter("active == true || active == null");
query.setFilter("active");
}
query.setOrdering("id asc");
return query.executeList();
@ -473,9 +473,6 @@ final class ProjectQueryManager extends QueryManager implements IQueryManager {
if (project.getParent() != null && !Boolean.TRUE.equals(project.getParent().isActive())){
throw new IllegalArgumentException("An inactive Parent cannot be selected as parent");
}
if (project.isActive() == null) {
project.setActive(Boolean.TRUE);
}
final Project oldLatestProject = project.isLatest() ? getLatestProjectVersion(project.getName()) : null;
final Project result = callInTransaction(() -> {
// Remove isLatest flag from current latest project version, if the new project will be the latest