diff options
Diffstat (limited to 'store/sql_post_store.go')
-rw-r--r-- | store/sql_post_store.go | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/store/sql_post_store.go b/store/sql_post_store.go index 4ea28507b..297d60397 100644 --- a/store/sql_post_store.go +++ b/store/sql_post_store.go @@ -5,9 +5,11 @@ package store import ( "fmt" + "regexp" + "strings" + "github.com/mattermost/platform/model" "github.com/mattermost/platform/utils" - "strings" ) type SqlPostStore struct { @@ -35,11 +37,6 @@ func NewSqlPostStore(sqlStore *SqlStore) PostStore { } func (s SqlPostStore) UpgradeSchemaIfNeeded() { - - // These execs are for upgrading currently created databases to full utf8mb4 compliance - // Will be removed as seen fit for upgrading - s.GetMaster().Exec("ALTER TABLE Posts charset=utf8mb4") - s.GetMaster().Exec("ALTER TABLE Posts MODIFY COLUMN Message varchar(4000) CHARACTER SET utf8mb4") } func (s SqlPostStore) CreateIndexesIfNotExists() { @@ -291,7 +288,7 @@ func (s SqlPostStore) GetPostsSince(channelId string, time int64) StoreChannel { WHERE (UpdateAt > :Time AND ChannelId = :ChannelId) - LIMIT 100) + LIMIT 1000) UNION (SELECT * @@ -307,7 +304,7 @@ func (s SqlPostStore) GetPostsSince(channelId string, time int64) StoreChannel { WHERE UpdateAt > :Time AND ChannelId = :ChannelId - LIMIT 100) temp_tab)) + LIMIT 1000) temp_tab)) ORDER BY CreateAt DESC`, map[string]interface{}{"ChannelId": channelId, "Time": time}) @@ -319,7 +316,9 @@ func (s SqlPostStore) GetPostsSince(channelId string, time int64) StoreChannel { for _, p := range posts { list.AddPost(p) - list.AddOrder(p.Id) + if p.UpdateAt > time { + list.AddOrder(p.Id) + } } result.Data = list @@ -361,7 +360,7 @@ func (s SqlPostStore) getParentsPosts(channelId string, offset int, limit int) S var posts []*model.Post _, err := s.GetReplica().Select(&posts, - `SELECT + `SELECT q2.* FROM Posts q2 @@ -369,7 +368,7 @@ func (s SqlPostStore) getParentsPosts(channelId string, offset int, limit int) S (SELECT DISTINCT q3.RootId FROM - (SELECT + (SELECT RootId FROM Posts @@ -377,7 +376,8 @@ func (s SqlPostStore) getParentsPosts(channelId string, offset int, limit int) S ChannelId = :ChannelId1 AND DeleteAt = 0 ORDER BY CreateAt DESC - LIMIT :Limit OFFSET :Offset) q3) q1 ON q1.RootId = q2.RootId + LIMIT :Limit OFFSET :Offset) q3 + WHERE q3.RootId != '') q1 ON q1.RootId = q2.Id WHERE ChannelId = :ChannelId2 AND DeleteAt = 0 @@ -419,6 +419,12 @@ func (s SqlPostStore) Search(teamId string, userId string, terms string, isHasht var posts []*model.Post if utils.Cfg.SqlSettings.DriverName == "postgres" { + + // Parse text for wildcards + if wildcard, err := regexp.Compile("\\*($| )"); err == nil { + terms = wildcard.ReplaceAllLiteralString(terms, ":* ") + } + searchQuery := fmt.Sprintf(`SELECT * FROM |