fix(09): WR-08 search non-text list columns as text instead of failing in SQL

This commit is contained in:
Jakub Zych
2026-10-01 21:11:38 +02:00
parent b026aec162
commit 8b48eea4e1
2 changed files with 45 additions and 1 deletions

View File

@@ -291,7 +291,9 @@ func applyListSearch(db *gorm.DB, controller pact.AdminController, schema *ListS
} else if !identifier(column) {
return nil, listInvalid("search", "is not searchable")
}
parts = append(parts, fmt.Sprintf("LOWER(%s) LIKE ? ESCAPE '\\'", qualifiedColumn(db, table, column)))
// CAST makes a numeric, date or boolean column searchable as its text
// form (Winter casts to TEXT too); PostgreSQL has no lower(integer).
parts = append(parts, fmt.Sprintf("LOWER(CAST(%s AS TEXT)) LIKE ? ESCAPE '\\'", qualifiedColumn(db, table, column)))
args = append(args, pattern)
}
return db.Where(strings.Join(parts, " OR "), args...), nil