types(fix) product search sql

This commit is contained in:
Theo Technicguy 2023-08-24 18:04:45 +02:00
parent 6b115b5439
commit b39dc1c095
Signed by: theo.technicguy
GPG Key ID: 3BC661201BCA53D9
1 changed files with 3 additions and 3 deletions

View File

@ -82,14 +82,14 @@ func (ps *ProductSearch) BuildTagSearch() string {
func (ps *ProductSearch) BuildSearch() string {
sql := `SELECT DISTINCT p.*
FROM Product p
JOIN ProductTagging ptg ON p.ProductID = ptg.ProductID
JOIN ProductTag pt ON ptg.TagID = pt.TagID
LEFT OUTER JOIN ProductTagging ptg ON p.ProductID = ptg.ProductID
LEFT OUTER JOIN ProductTag pt ON ptg.TagID = pt.TagID
`
filters := []string{}
if ps.Ean != "" {
filters = append(filters, "p.ean LIKE '%%"+ps.Ean+"%%'")
filters = append(filters, fmt.Sprintf("p.ean LIKE '%%%s%%'", ps.Ean))
}
if len(ps.Names) > 0 {
filters = append(filters, ps.BuildNamesSearch())