projects
/
quanweb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Make searches more inclusive.
[quanweb.git]
/
main
/
db.go
diff --git
a/main/db.go
b/main/db.go
index 21c6818d8c5e6ad23998d30cd5ce10b35a881b94..53c0a2c37b0959cf9ca522067e1bc463ea6a1671 100644
(file)
--- a/
main/db.go
+++ b/
main/db.go
@@
-4,6
+4,7
@@
import (
"database/sql"
"fmt"
_ "github.com/lib/pq"
"database/sql"
"fmt"
_ "github.com/lib/pq"
+ "strings"
"strconv"
"sync"
)
"strconv"
"sync"
)
@@
-183,8
+184,6
@@
func queryBookPathById(id int) (string) {
}
func queryIds(criteria []SearchTerm) []int {
}
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"
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"
@@
-197,18
+196,22
@@
func queryIds(criteria []SearchTerm) []int {
} else {
query += " AND "
}
} else {
query += " AND "
}
+
+ text := criterion.Text
+
switch criterion.Attribute {
case Author:
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:
case Series:
- query += "
s.descr LIKE $" + strconv.Itoa(i + 1)
+ query += "
UPPER(s.descr) LIKE UPPER($" + strconv.Itoa(i + 1) + ")"
case Title:
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
}
default:
report("Error: unrecognized search field in queryIds(): " + criterion.Attribute.String(), nil)
return nil
}
- args[i] =
criterion.T
ext
+ args[i] =
t
ext
}
query += " ORDER BY b.path"
}
query += " ORDER BY b.path"