fix(09): WR-08 search non-text list columns as text instead of failing in SQL
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user