Do a case insensitive search for tags

This change switches to a case insensitive search for pool tags.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
Gabriel Adrian Samfira 2024-09-27 07:50:24 +00:00
parent f64ffa8d92
commit c319341ec5
2 changed files with 2 additions and 2 deletions

View file

@ -206,7 +206,7 @@ func (s *sqlDatabase) findPoolByTags(id string, poolType params.GithubEntityType
}
var pools []Pool
where := fmt.Sprintf("tags.name in ? and %s = ? and enabled = true", fieldName)
where := fmt.Sprintf("tags.name COLLATE NOCASE in ? and %s = ? and enabled = true", fieldName)
q := s.conn.Joins("JOIN pool_tags on pool_tags.pool_id=pools.id").
Joins("JOIN tags on tags.id=pool_tags.tag_id").
Group("pools.id").

View file

@ -331,7 +331,7 @@ func (s *sqlDatabase) sqlToParamsUser(user User) params.User {
func (s *sqlDatabase) getOrCreateTag(tx *gorm.DB, tagName string) (Tag, error) {
var tag Tag
q := tx.Where("name = ?", tagName).First(&tag)
q := tx.Where("name = ? COLLATE NOCASE", tagName).First(&tag)
if q.Error == nil {
return tag, nil
}