summaryrefslogtreecommitdiffstats
path: root/store/sql_post_store.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2015-08-31 09:03:11 -0400
committerChristopher Speller <crspeller@gmail.com>2015-08-31 09:03:11 -0400
commitccb5d076d5fbb96de29492633ca83ecc30f36b37 (patch)
treeb04191979b43f14a05454488bc1248084c010ec9 /store/sql_post_store.go
parent2384fe0c7b682aa9b97f2cd33b3bfa24a79b98c6 (diff)
parentb69221aa7fec759edb856e7b44ee24769b87486d (diff)
downloadchat-ccb5d076d5fbb96de29492633ca83ecc30f36b37.tar.gz
chat-ccb5d076d5fbb96de29492633ca83ecc30f36b37.tar.bz2
chat-ccb5d076d5fbb96de29492633ca83ecc30f36b37.zip
Merge pull request #475 from nickago/MM-1773
MM-1773a Add wildcard searching for postgresql
Diffstat (limited to 'store/sql_post_store.go')
-rw-r--r--store/sql_post_store.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/store/sql_post_store.go b/store/sql_post_store.go
index cd668b13c..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 {
@@ -358,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
@@ -366,7 +368,7 @@ func (s SqlPostStore) getParentsPosts(channelId string, offset int, limit int) S
(SELECT DISTINCT
q3.RootId
FROM
- (SELECT
+ (SELECT
RootId
FROM
Posts
@@ -417,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