minor tweaks to make sure mysql still runs

Этот коммит содержится в:
=Corey Hulen
2015-07-12 19:12:23 -08:00
родитель 34d56294a2
Коммит af63080c0d
5 изменённых файлов: 28 добавлений и 9 удалений

Просмотреть файл

@@ -516,6 +516,7 @@ func TestDeletePosts(t *testing.T) {
post3a1 := &model.Post{ChannelId: channel1.Id, Message: "a" + model.NewId() + "a", RootId: post3.Id} post3a1 := &model.Post{ChannelId: channel1.Id, Message: "a" + model.NewId() + "a", RootId: post3.Id}
post3a1 = Client.Must(Client.CreatePost(post3a1)).Data.(*model.Post) post3a1 = Client.Must(Client.CreatePost(post3a1)).Data.(*model.Post)
time.Sleep(10 * time.Millisecond)
Client.Must(Client.DeletePost(channel1.Id, post3.Id)) Client.Must(Client.DeletePost(channel1.Id, post3.Id))
r2 := Client.Must(Client.GetPosts(channel1.Id, 0, 10, "")).Data.(*model.PostList) r2 := Client.Must(Client.GetPosts(channel1.Id, 0, 10, "")).Data.(*model.PostList)

Просмотреть файл

@@ -23,9 +23,9 @@
"AnalyticsUrl": "" "AnalyticsUrl": ""
}, },
"SqlSettings": { "SqlSettings": {
"DriverName": "postgres", "DriverName": "mysql",
"DataSource": "postgres://mmuser:password@localhost:5432/mattermost_test?sslmode=disable&connect_timeout=10", "DataSource": "mmuser:mostest@tcp(dockerhost:3306)/mattermost_test",
"DataSourceReplicas": ["postgres://mmuser:password@localhost:5432/mattermost_test?sslmode=disable&connect_timeout=10"], "DataSourceReplicas": ["mmuser:mostest@tcp(dockerhost:3306)/mattermost_test"],
"MaxIdleConns": 10, "MaxIdleConns": 10,
"MaxOpenConns": 10, "MaxOpenConns": 10,
"Trace": false, "Trace": false,

Просмотреть файл

@@ -11,6 +11,7 @@ import (
"net/url" "net/url"
"strconv" "strconv"
"strings" "strings"
"time"
) )
const ( const (
@@ -92,6 +93,7 @@ func getCookie(name string, resp *http.Response) *http.Cookie {
func (c *Client) Must(result *Result, err *AppError) *Result { func (c *Client) Must(result *Result, err *AppError) *Result {
if err != nil { if err != nil {
time.Sleep(time.Second)
panic(err) panic(err)
} }

Просмотреть файл

@@ -494,8 +494,10 @@ func (s SqlChannelStore) UpdateLastViewedAt(channelId string, userId string) Sto
go func() { go func() {
result := StoreResult{} result := StoreResult{}
_, err := s.GetMaster().Exec( var query string
`UPDATE
if utils.Cfg.SqlSettings.DriverName == "postgres" {
query = `UPDATE
ChannelMembers ChannelMembers
SET SET
MentionCount = 0, MentionCount = 0,
@@ -507,8 +509,22 @@ func (s SqlChannelStore) UpdateLastViewedAt(channelId string, userId string) Sto
WHERE WHERE
Channels.Id = ChannelMembers.ChannelId Channels.Id = ChannelMembers.ChannelId
AND UserId = :UserId AND UserId = :UserId
AND ChannelId = :ChannelId`, AND ChannelId = :ChannelId`
map[string]interface{}{"ChannelId": channelId, "UserId": userId}) } else if utils.Cfg.SqlSettings.DriverName == "mysql" {
query = `UPDATE
ChannelMembers, Channels
SET
ChannelMembers.MentionCount = 0,
ChannelMembers.MsgCount = Channels.TotalMsgCount,
ChannelMembers.LastViewedAt = Channels.LastPostAt,
ChannelMembers.LastUpdateAt = Channels.LastPostAt
WHERE
Channels.Id = ChannelMembers.ChannelId
AND UserId = :UserId
AND ChannelId = :ChannelId`
}
_, err := s.GetMaster().Exec(query, map[string]interface{}{"ChannelId": channelId, "UserId": userId})
if err != nil { if err != nil {
result.Err = model.NewAppError("SqlChannelStore.UpdateLastViewedAt", "We couldn't update the last viewed at time", "channel_id="+channelId+", user_id="+userId+", "+err.Error()) result.Err = model.NewAppError("SqlChannelStore.UpdateLastViewedAt", "We couldn't update the last viewed at time", "channel_id="+channelId+", user_id="+userId+", "+err.Error())
} }

Просмотреть файл

@@ -301,7 +301,7 @@ func (s SqlPostStore) getRootPosts(channelId string, offset int, limit int) Stor
result := StoreResult{} result := StoreResult{}
var posts []*model.Post var posts []*model.Post
_, err := s.GetReplica().Select(&posts, "SELECT * FROM Posts WHERE ChannelId = :ChannelId AND DeleteAt = 0 ORDER BY CreateAt DESC OFFSET :Offset LIMIT :Limit", map[string]interface{}{"ChannelId": channelId, "Offset": offset, "Limit": limit}) _, err := s.GetReplica().Select(&posts, "SELECT * FROM Posts WHERE ChannelId = :ChannelId AND DeleteAt = 0 ORDER BY CreateAt DESC LIMIT :Limit OFFSET :Offset", map[string]interface{}{"ChannelId": channelId, "Offset": offset, "Limit": limit})
if err != nil { if err != nil {
result.Err = model.NewAppError("SqlPostStore.GetLinearPosts", "We couldn't get the posts for the channel", "channelId="+channelId+err.Error()) result.Err = model.NewAppError("SqlPostStore.GetLinearPosts", "We couldn't get the posts for the channel", "channelId="+channelId+err.Error())
} else { } else {
@@ -339,7 +339,7 @@ func (s SqlPostStore) getParentsPosts(channelId string, offset int, limit int) S
ChannelId = :ChannelId1 ChannelId = :ChannelId1
AND DeleteAt = 0 AND DeleteAt = 0
ORDER BY CreateAt DESC ORDER BY CreateAt DESC
OFFSET :Offset LIMIT :Limit) q3) q1 ON q1.RootId = q2.RootId LIMIT :Limit OFFSET :Offset) q3) q1 ON q1.RootId = q2.RootId
WHERE WHERE
ChannelId = :ChannelId2 ChannelId = :ChannelId2
AND DeleteAt = 0 AND DeleteAt = 0