Add ILIKE for every LIKE query
continuous-integration/drone/pr Build is failing
Details
continuous-integration/drone/pr Build is failing
Details
This commit is contained in:
parent
9c2a59582a
commit
d0bde0cfd3
|
@ -21,9 +21,11 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"code.vikunja.io/api/pkg/config"
|
||||
"code.vikunja.io/api/pkg/log"
|
||||
"code.vikunja.io/api/pkg/user"
|
||||
"code.vikunja.io/web"
|
||||
|
||||
"xorm.io/builder"
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
@ -200,7 +202,11 @@ func getLabelsByTaskIDs(s *xorm.Session, opts *LabelByTaskIDsOptions) (ls []*lab
|
|||
if len(ids) > 0 {
|
||||
cond = builder.And(cond, builder.In("labels.id", ids))
|
||||
} else {
|
||||
cond = builder.And(cond, &builder.Like{"labels.title", "%" + opts.Search + "%"})
|
||||
if config.DatabaseType.GetString() == "postgres" {
|
||||
cond = builder.And(cond, builder.Expr("labels.title ILIKE ?", "%"+opts.Search+"%"))
|
||||
} else {
|
||||
cond = builder.And(cond, &builder.Like{"labels.title", "%" + opts.Search + "%"})
|
||||
}
|
||||
}
|
||||
|
||||
limit, start := getLimitFromPageIndex(opts.Page, opts.PerPage)
|
||||
|
|
|
@ -20,12 +20,14 @@ import (
|
|||
"errors"
|
||||
"time"
|
||||
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
|
||||
"code.vikunja.io/api/pkg/config"
|
||||
"code.vikunja.io/api/pkg/user"
|
||||
"code.vikunja.io/api/pkg/utils"
|
||||
|
||||
"code.vikunja.io/web"
|
||||
"github.com/golang-jwt/jwt"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
"xorm.io/builder"
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
|
@ -205,8 +207,24 @@ func (share *LinkSharing) ReadAll(s *xorm.Session, a web.Auth, search string, pa
|
|||
limit, start := getLimitFromPageIndex(page, perPage)
|
||||
|
||||
var shares []*LinkSharing
|
||||
var where builder.Cond
|
||||
where = builder.Or(
|
||||
builder.Like{"hash", "%" + search + "%"},
|
||||
builder.Like{"name", "%" + search + "%"},
|
||||
)
|
||||
|
||||
if config.DatabaseType.GetString() == "postgres" {
|
||||
where = builder.Or(
|
||||
builder.Expr("hash ILIKE ?", "%"+search+"%"),
|
||||
builder.Expr("name ILIKE ?", "%"+search+"%"),
|
||||
)
|
||||
}
|
||||
query := s.
|
||||
Where("list_id = ? AND hash LIKE ?", share.ListID, "%"+search+"%")
|
||||
Where(builder.And(
|
||||
builder.Eq{"list_id": share.ListID},
|
||||
where,
|
||||
))
|
||||
|
||||
if limit > 0 {
|
||||
query = query.Limit(limit, start)
|
||||
}
|
||||
|
|
|
@ -406,7 +406,11 @@ func getRawListsForUser(s *xorm.Session, opts *listOptions) (lists []*List, resu
|
|||
if len(ids) > 0 {
|
||||
filterCond = builder.In("l.id", ids)
|
||||
} else {
|
||||
filterCond = &builder.Like{"l.title", "%" + opts.search + "%"}
|
||||
if config.DatabaseType.GetString() == "postgres" {
|
||||
filterCond = builder.Expr("l.title ILIKE ?", "%"+opts.search+"%")
|
||||
} else {
|
||||
filterCond = &builder.Like{"l.title", "%" + opts.search + "%"}
|
||||
}
|
||||
}
|
||||
|
||||
// Gets all Lists where the user is either owner or in a team which has access to the list
|
||||
|
|
|
@ -19,9 +19,11 @@ package models
|
|||
import (
|
||||
"time"
|
||||
|
||||
"code.vikunja.io/api/pkg/config"
|
||||
"code.vikunja.io/api/pkg/events"
|
||||
|
||||
"code.vikunja.io/web"
|
||||
"xorm.io/builder"
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
|
@ -194,11 +196,16 @@ func (tl *TeamList) ReadAll(s *xorm.Session, a web.Auth, search string, page int
|
|||
|
||||
// Get the teams
|
||||
all := []*TeamWithRight{}
|
||||
var where builder.Cond
|
||||
where = builder.Like{"teams.name", "%" + search + "%"}
|
||||
if config.DatabaseType.GetString() == "postgres" {
|
||||
where = builder.Expr("teams.name ILIKE ?", "%"+search+"%")
|
||||
}
|
||||
query := s.
|
||||
Table("teams").
|
||||
Join("INNER", "team_lists", "team_id = teams.id").
|
||||
Where("team_lists.list_id = ?", tl.ListID).
|
||||
Where("teams.name LIKE ?", "%"+search+"%")
|
||||
Where(where)
|
||||
if limit > 0 {
|
||||
query = query.Limit(limit, start)
|
||||
}
|
||||
|
|
|
@ -17,7 +17,9 @@
|
|||
package models
|
||||
|
||||
import (
|
||||
"code.vikunja.io/api/pkg/config"
|
||||
"time"
|
||||
"xorm.io/builder"
|
||||
|
||||
"code.vikunja.io/api/pkg/events"
|
||||
|
||||
|
@ -201,10 +203,15 @@ func (lu *ListUser) ReadAll(s *xorm.Session, a web.Auth, search string, page int
|
|||
|
||||
// Get all users
|
||||
all := []*UserWithRight{}
|
||||
var where builder.Cond
|
||||
where = builder.Like{"users.username", "%" + search + "%"}
|
||||
if config.DatabaseType.GetString() == "postgres" {
|
||||
where = builder.Expr("users.username ILIKE ?", "%"+search+"%")
|
||||
}
|
||||
query := s.
|
||||
Join("INNER", "users_lists", "user_id = users.id").
|
||||
Where("users_lists.list_id = ?", lu.ListID).
|
||||
Where("users.username LIKE ?", "%"+search+"%")
|
||||
Where(where)
|
||||
if limit > 0 {
|
||||
query = query.Limit(limit, start)
|
||||
}
|
||||
|
|
|
@ -22,10 +22,11 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"code.vikunja.io/api/pkg/config"
|
||||
"code.vikunja.io/api/pkg/events"
|
||||
|
||||
"code.vikunja.io/api/pkg/log"
|
||||
"code.vikunja.io/api/pkg/user"
|
||||
|
||||
"code.vikunja.io/web"
|
||||
"xorm.io/builder"
|
||||
"xorm.io/xorm"
|
||||
|
@ -201,6 +202,9 @@ func makeNamespaceSlice(namespaces map[int64]*NamespaceWithLists, userMap map[in
|
|||
|
||||
func getNamespaceFilterCond(search string) (filterCond builder.Cond) {
|
||||
filterCond = &builder.Like{"namespaces.title", "%" + search + "%"}
|
||||
if config.DatabaseType.GetString() == "postgres" {
|
||||
filterCond = builder.Expr("namespaces.title ILIKE ?", "%"+search+"%")
|
||||
}
|
||||
|
||||
if search == "" {
|
||||
return
|
||||
|
|
|
@ -19,9 +19,11 @@ package models
|
|||
import (
|
||||
"time"
|
||||
|
||||
"code.vikunja.io/api/pkg/config"
|
||||
"code.vikunja.io/api/pkg/events"
|
||||
|
||||
"code.vikunja.io/web"
|
||||
|
||||
"xorm.io/builder"
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
|
@ -181,11 +183,16 @@ func (tn *TeamNamespace) ReadAll(s *xorm.Session, a web.Auth, search string, pag
|
|||
|
||||
limit, start := getLimitFromPageIndex(page, perPage)
|
||||
|
||||
var where builder.Cond
|
||||
where = builder.Like{"teams.name", "%" + search + "%"}
|
||||
if config.DatabaseType.GetString() == "postgres" {
|
||||
where = builder.Expr("teams.name ILIKE ?", "%"+search+"%")
|
||||
}
|
||||
query := s.
|
||||
Table("teams").
|
||||
Join("INNER", "team_namespaces", "team_id = teams.id").
|
||||
Where("team_namespaces.namespace_id = ?", tn.NamespaceID).
|
||||
Where("teams.name LIKE ?", "%"+search+"%")
|
||||
Where(where)
|
||||
if limit > 0 {
|
||||
query = query.Limit(limit, start)
|
||||
}
|
||||
|
|
|
@ -19,10 +19,12 @@ package models
|
|||
import (
|
||||
"time"
|
||||
|
||||
"code.vikunja.io/api/pkg/config"
|
||||
"code.vikunja.io/api/pkg/events"
|
||||
|
||||
user2 "code.vikunja.io/api/pkg/user"
|
||||
"code.vikunja.io/web"
|
||||
|
||||
"xorm.io/builder"
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
|
@ -187,11 +189,15 @@ func (nu *NamespaceUser) ReadAll(s *xorm.Session, a web.Auth, search string, pag
|
|||
all := []*UserWithRight{}
|
||||
|
||||
limit, start := getLimitFromPageIndex(page, perPage)
|
||||
|
||||
var where builder.Cond
|
||||
where = builder.Like{"users.username", "%" + search + "%"}
|
||||
if config.DatabaseType.GetString() == "postgres" {
|
||||
where = builder.Expr("users.username ILIKE ?", "%"+search+"%")
|
||||
}
|
||||
query := s.
|
||||
Join("INNER", "users_namespaces", "user_id = users.id").
|
||||
Where("users_namespaces.namespace_id = ?", nu.NamespaceID).
|
||||
Where("users.username LIKE ?", "%"+search+"%")
|
||||
Where(where)
|
||||
if limit > 0 {
|
||||
query = query.Limit(limit, start)
|
||||
}
|
||||
|
|
|
@ -17,7 +17,9 @@
|
|||
package models
|
||||
|
||||
import (
|
||||
"code.vikunja.io/api/pkg/config"
|
||||
"time"
|
||||
"xorm.io/builder"
|
||||
|
||||
"code.vikunja.io/api/pkg/events"
|
||||
|
||||
|
@ -269,10 +271,15 @@ func (la *TaskAssginee) ReadAll(s *xorm.Session, a web.Auth, search string, page
|
|||
limit, start := getLimitFromPageIndex(page, perPage)
|
||||
|
||||
var taskAssignees []*user.User
|
||||
var where builder.Cond
|
||||
where = builder.Like{"users.username", "%" + search + "%"}
|
||||
if config.DatabaseType.GetString() == "postgres" {
|
||||
where = builder.Expr("users.username ILIKE ?", "%"+search+"%")
|
||||
}
|
||||
query := s.Table("task_assignees").
|
||||
Select("users.*").
|
||||
Join("INNER", "users", "task_assignees.user_id = users.id").
|
||||
Where("task_id = ? AND users.username LIKE ?", la.TaskID, "%"+search+"%")
|
||||
Where(builder.And(builder.Eq{"task_id": la.TaskID}, where))
|
||||
if limit > 0 {
|
||||
query = query.Limit(limit, start)
|
||||
}
|
||||
|
|
|
@ -19,12 +19,13 @@ package models
|
|||
import (
|
||||
"time"
|
||||
|
||||
"code.vikunja.io/api/pkg/config"
|
||||
"code.vikunja.io/api/pkg/events"
|
||||
|
||||
"xorm.io/xorm"
|
||||
|
||||
"code.vikunja.io/api/pkg/user"
|
||||
"code.vikunja.io/web"
|
||||
|
||||
"xorm.io/builder"
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
// TaskComment represents a task comment
|
||||
|
@ -216,8 +217,13 @@ func (tc *TaskComment) ReadAll(s *xorm.Session, auth web.Auth, search string, pa
|
|||
limit, start := getLimitFromPageIndex(page, perPage)
|
||||
|
||||
comments := []*TaskComment{}
|
||||
var where builder.Cond
|
||||
where = builder.Like{"comment", "%" + search + "%"}
|
||||
if config.DatabaseType.GetString() == "postgres" {
|
||||
where = builder.Expr("comment ILIKE ?", "%"+search+"%")
|
||||
}
|
||||
query := s.
|
||||
Where("task_id = ? AND comment like ?", tc.TaskID, "%"+search+"%").
|
||||
Where(builder.And(builder.Eq{"task_id": tc.TaskID}, where)).
|
||||
Join("LEFT", "users", "users.id = task_comments.author_id")
|
||||
if limit > 0 {
|
||||
query = query.Limit(limit, start)
|
||||
|
|
|
@ -19,13 +19,13 @@ package models
|
|||
import (
|
||||
"time"
|
||||
|
||||
"code.vikunja.io/api/pkg/config"
|
||||
"code.vikunja.io/api/pkg/events"
|
||||
|
||||
"xorm.io/xorm"
|
||||
|
||||
"code.vikunja.io/api/pkg/user"
|
||||
"code.vikunja.io/web"
|
||||
|
||||
"xorm.io/builder"
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
// Team holds a team object
|
||||
|
@ -212,11 +212,16 @@ func (t *Team) ReadAll(s *xorm.Session, a web.Auth, search string, page int, per
|
|||
limit, start := getLimitFromPageIndex(page, perPage)
|
||||
|
||||
all := []*Team{}
|
||||
var where builder.Cond
|
||||
where = builder.Like{"teams.name", "%" + search + "%"}
|
||||
if config.DatabaseType.GetString() == "postgres" {
|
||||
where = builder.Expr("teams.name ILIKE ?", "%"+search+"%")
|
||||
}
|
||||
query := s.Select("teams.*").
|
||||
Table("teams").
|
||||
Join("INNER", "team_members", "team_members.team_id = teams.id").
|
||||
Where("team_members.user_id = ?", a.GetID()).
|
||||
Where("teams.name LIKE ?", "%"+search+"%")
|
||||
Where(where)
|
||||
if limit > 0 {
|
||||
query = query.Limit(limit, start)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue