"database/sql"
"fmt"
_ "github.com/lib/pq"
+ "strings"
"strconv"
"sync"
)
}
func queryIds(criteria []SearchTerm) []int {
- fmt.Println("queryIds():", criteria)
-
query := "SELECT b.id FROM Books b" +
" INNER JOIN Authors a ON a.id=b.author" +
" LEFT OUTER JOIN Series s ON s.id=b.series"
} else {
query += " AND "
}
+
+ text := criterion.Text
+
switch criterion.Attribute {
case Author:
- query += " a.grouping LIKE $" + strconv.Itoa(i + 1)
+ query += " UPPER(a.grouping) LIKE UPPER($" + strconv.Itoa(i + 1) + ")"
+ text = strings.Replace(text, " ", "", -1) // Remove spaces
case Series:
- query += " s.descr LIKE $" + strconv.Itoa(i + 1)
+ query += " UPPER(s.descr) LIKE UPPER($" + strconv.Itoa(i + 1) + ")"
case Title:
- query += " b.title LIKE $" + strconv.Itoa(i + 1)
+ query += " UPPER(b.title) LIKE UPPER($" + strconv.Itoa(i + 1) + ")"
default:
report("Error: unrecognized search field in queryIds(): " + criterion.Attribute.String(), nil)
return nil
}
- args[i] = criterion.Text
+ args[i] = text
}
query += " ORDER BY b.path"