fix(api): handle Author sort name generation above field length (#2276)

This commit is contained in:
James Ward
2026-08-07 16:55:57 -04:00
committed by GitHub
parent 7644e771a0
commit c71893c669
3 changed files with 25 additions and 4 deletions
@@ -26,7 +26,7 @@ public class AuthorEntity {
@Column(name = "name")
private String name;
@Column(name = "sort_name")
@Column(name = "sort_name", length = 255)
private String sortName;
@Column(name = "sort_name_locked", nullable = false)
@@ -60,6 +60,12 @@ public class AuthorEntity {
public void computeSortName() {
if (!sortNameLocked) {
sortName = AuthorSortName.compute(name);
if (sortName != null && sortName.length() > 255) {
// The sort name MAY end up longer than 255 characters and hit
// limits.
sortName = sortName.substring(0, 255);
}
}
}
@@ -44,9 +44,7 @@ public class PopulateAuthorSortNameMigration implements Migration {
}
for (var author : authors) {
if (!author.isSortNameLocked()) {
author.setSortName(AuthorSortName.compute(author.getName()));
}
author.computeSortName();
}
authorRepository.saveAll(authors);