Trim title before insert/update to database to match the size requirements of database (#32498) (#32507)

This commit is contained in:
Lunny Xiao 2024-11-14 18:06:31 -08:00 committed by GitHub
parent f79f8e13e3
commit 781310df77
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 18 additions and 0 deletions

View file

@ -257,6 +257,7 @@ func GetSearchOrderByBySortType(sortType string) db.SearchOrderBy {
}
// NewProject creates a new Project
// The title will be cut off at 255 characters if it's longer than 255 characters.
func NewProject(ctx context.Context, p *Project) error {
if !IsBoardTypeValid(p.BoardType) {
p.BoardType = BoardTypeNone
@ -276,6 +277,8 @@ func NewProject(ctx context.Context, p *Project) error {
}
defer committer.Close()
p.Title, _ = util.SplitStringAtByteN(p.Title, 255)
if err := db.Insert(ctx, p); err != nil {
return err
}
@ -331,6 +334,7 @@ func UpdateProject(ctx context.Context, p *Project) error {
p.CardType = CardTypeTextOnly
}
p.Title, _ = util.SplitStringAtByteN(p.Title, 255)
_, err := db.GetEngine(ctx).ID(p.ID).Cols(
"title",
"description",