set to default value with config is missing (#7320)
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
4c1f467442
Коммит
651dd33b29
@@ -1305,7 +1305,7 @@ func (s SqlChannelStore) UpdateLastViewedAt(channelIds []string, userId string)
|
||||
idQuery += "ChannelId = :channelId" + strconv.Itoa(index)
|
||||
}
|
||||
|
||||
if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
query = `UPDATE
|
||||
ChannelMembers
|
||||
SET
|
||||
@@ -1319,7 +1319,7 @@ func (s SqlChannelStore) UpdateLastViewedAt(channelIds []string, userId string)
|
||||
Channels.Id = ChannelMembers.ChannelId
|
||||
AND UserId = :UserId
|
||||
AND (` + idQuery + `)`
|
||||
} else if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
} else if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
query = `UPDATE
|
||||
ChannelMembers, Channels
|
||||
SET
|
||||
@@ -1597,7 +1597,7 @@ func (s SqlChannelStore) performSearch(searchQuery string, term string, paramete
|
||||
|
||||
if term == "" {
|
||||
searchQuery = strings.Replace(searchQuery, "SEARCH_CLAUSE", "", 1)
|
||||
} else if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
} else if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
splitTerm := strings.Fields(term)
|
||||
for i, t := range strings.Fields(term) {
|
||||
if i == len(splitTerm)-1 {
|
||||
@@ -1611,7 +1611,7 @@ func (s SqlChannelStore) performSearch(searchQuery string, term string, paramete
|
||||
|
||||
searchClause := fmt.Sprintf("AND (%s) @@ to_tsquery('simple', :Term)", "Name || ' ' || DisplayName")
|
||||
searchQuery = strings.Replace(searchQuery, "SEARCH_CLAUSE", searchClause, 1)
|
||||
} else if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
} else if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
splitTerm := strings.Fields(term)
|
||||
for i, t := range strings.Fields(term) {
|
||||
splitTerm[i] = "+" + t + "*"
|
||||
|
||||
@@ -529,9 +529,9 @@ func (as SqlOAuthStore) deleteOAuthAppSessions(transaction *gorp.Transaction, cl
|
||||
result := StoreResult{}
|
||||
|
||||
query := ""
|
||||
if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
query = "DELETE FROM Sessions s USING OAuthAccessData o WHERE o.Token = s.Token AND o.ClientId = :Id"
|
||||
} else if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
} else if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
query = "DELETE s.* FROM Sessions s INNER JOIN OAuthAccessData o ON o.Token = s.Token WHERE o.ClientId = :Id"
|
||||
}
|
||||
|
||||
|
||||
@@ -1033,7 +1033,7 @@ func (s SqlPostStore) Search(teamId string, userId string, params *model.SearchP
|
||||
if terms == "" {
|
||||
// we've already confirmed that we have a channel or user to search for
|
||||
searchQuery = strings.Replace(searchQuery, "SEARCH_CLAUSE", "", 1)
|
||||
} else if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
} else if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
// Parse text for wildcards
|
||||
if wildcard, err := regexp.Compile("\\*($| )"); err == nil {
|
||||
terms = wildcard.ReplaceAllLiteralString(terms, ":* ")
|
||||
@@ -1047,7 +1047,7 @@ func (s SqlPostStore) Search(teamId string, userId string, params *model.SearchP
|
||||
|
||||
searchClause := fmt.Sprintf("AND %s @@ to_tsquery(:Terms)", searchType)
|
||||
searchQuery = strings.Replace(searchQuery, "SEARCH_CLAUSE", searchClause, 1)
|
||||
} else if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
} else if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
searchClause := fmt.Sprintf("AND MATCH (%s) AGAINST (:Terms IN BOOLEAN MODE)", searchType)
|
||||
searchQuery = strings.Replace(searchQuery, "SEARCH_CLAUSE", searchClause, 1)
|
||||
|
||||
@@ -1121,7 +1121,7 @@ func (s SqlPostStore) AnalyticsUserCountsWithPostsByDay(teamId string) StoreChan
|
||||
ORDER BY Name DESC
|
||||
LIMIT 30`
|
||||
|
||||
if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
query =
|
||||
`SELECT
|
||||
TO_CHAR(DATE(TO_TIMESTAMP(Posts.CreateAt / 1000)), 'YYYY-MM-DD') AS Name, COUNT(DISTINCT Posts.UserId) AS Value
|
||||
@@ -1184,7 +1184,7 @@ func (s SqlPostStore) AnalyticsPostCountsByDay(teamId string) StoreChannel {
|
||||
ORDER BY Name DESC
|
||||
LIMIT 30`
|
||||
|
||||
if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
query =
|
||||
`SELECT
|
||||
TO_CHAR(DATE(TO_TIMESTAMP(Posts.CreateAt / 1000)), 'YYYY-MM-DD') AS Name, Count(Posts.Id) AS Value
|
||||
|
||||
@@ -110,7 +110,7 @@ func (s SqlPreferenceStore) save(transaction *gorp.Transaction, preference *mode
|
||||
"Value": preference.Value,
|
||||
}
|
||||
|
||||
if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
if _, err := transaction.Exec(
|
||||
`INSERT INTO
|
||||
Preferences
|
||||
@@ -121,7 +121,7 @@ func (s SqlPreferenceStore) save(transaction *gorp.Transaction, preference *mode
|
||||
Value = :Value`, params); err != nil {
|
||||
result.Err = model.NewLocAppError("SqlPreferenceStore.save", "store.sql_preference.save.updating.app_error", nil, err.Error())
|
||||
}
|
||||
} else if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
} else if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
// postgres has no way to upsert values until version 9.5 and trying inserting and then updating causes transactions to abort
|
||||
count, err := transaction.SelectInt(
|
||||
`SELECT
|
||||
|
||||
@@ -222,9 +222,9 @@ func setupConnection(con_type string, driver string, dataSource string, maxIdle
|
||||
}
|
||||
|
||||
func (s *SqlSupplier) initConnection() {
|
||||
s.master = setupConnection("master", utils.Cfg.SqlSettings.DriverName,
|
||||
utils.Cfg.SqlSettings.DataSource, utils.Cfg.SqlSettings.MaxIdleConns,
|
||||
utils.Cfg.SqlSettings.MaxOpenConns, utils.Cfg.SqlSettings.Trace)
|
||||
s.master = setupConnection("master", *utils.Cfg.SqlSettings.DriverName,
|
||||
*utils.Cfg.SqlSettings.DataSource, *utils.Cfg.SqlSettings.MaxIdleConns,
|
||||
*utils.Cfg.SqlSettings.MaxOpenConns, utils.Cfg.SqlSettings.Trace)
|
||||
|
||||
if len(utils.Cfg.SqlSettings.DataSourceReplicas) == 0 {
|
||||
s.replicas = make([]*gorp.DbMap, 1)
|
||||
@@ -232,8 +232,8 @@ func (s *SqlSupplier) initConnection() {
|
||||
} else {
|
||||
s.replicas = make([]*gorp.DbMap, len(utils.Cfg.SqlSettings.DataSourceReplicas))
|
||||
for i, replica := range utils.Cfg.SqlSettings.DataSourceReplicas {
|
||||
s.replicas[i] = setupConnection(fmt.Sprintf("replica-%v", i), utils.Cfg.SqlSettings.DriverName, replica,
|
||||
utils.Cfg.SqlSettings.MaxIdleConns, utils.Cfg.SqlSettings.MaxOpenConns,
|
||||
s.replicas[i] = setupConnection(fmt.Sprintf("replica-%v", i), *utils.Cfg.SqlSettings.DriverName, replica,
|
||||
*utils.Cfg.SqlSettings.MaxIdleConns, *utils.Cfg.SqlSettings.MaxOpenConns,
|
||||
utils.Cfg.SqlSettings.Trace)
|
||||
}
|
||||
}
|
||||
@@ -243,8 +243,8 @@ func (s *SqlSupplier) initConnection() {
|
||||
} else {
|
||||
s.searchReplicas = make([]*gorp.DbMap, len(utils.Cfg.SqlSettings.DataSourceSearchReplicas))
|
||||
for i, replica := range utils.Cfg.SqlSettings.DataSourceSearchReplicas {
|
||||
s.searchReplicas[i] = setupConnection(fmt.Sprintf("search-replica-%v", i), utils.Cfg.SqlSettings.DriverName, replica,
|
||||
utils.Cfg.SqlSettings.MaxIdleConns, utils.Cfg.SqlSettings.MaxOpenConns,
|
||||
s.searchReplicas[i] = setupConnection(fmt.Sprintf("search-replica-%v", i), *utils.Cfg.SqlSettings.DriverName, replica,
|
||||
*utils.Cfg.SqlSettings.MaxIdleConns, *utils.Cfg.SqlSettings.MaxOpenConns,
|
||||
utils.Cfg.SqlSettings.Trace)
|
||||
}
|
||||
}
|
||||
@@ -312,7 +312,7 @@ func (ss *SqlSupplier) MarkSystemRanUnitTests() {
|
||||
}
|
||||
|
||||
func (ss *SqlSupplier) DoesTableExist(tableName string) bool {
|
||||
if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
count, err := ss.GetMaster().SelectInt(
|
||||
`SELECT count(relname) FROM pg_class WHERE relname=$1`,
|
||||
strings.ToLower(tableName),
|
||||
@@ -326,7 +326,7 @@ func (ss *SqlSupplier) DoesTableExist(tableName string) bool {
|
||||
|
||||
return count > 0
|
||||
|
||||
} else if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
} else if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
|
||||
count, err := ss.GetMaster().SelectInt(
|
||||
`SELECT
|
||||
@@ -357,7 +357,7 @@ func (ss *SqlSupplier) DoesTableExist(tableName string) bool {
|
||||
}
|
||||
|
||||
func (ss *SqlSupplier) DoesColumnExist(tableName string, columnName string) bool {
|
||||
if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
count, err := ss.GetMaster().SelectInt(
|
||||
`SELECT COUNT(0)
|
||||
FROM pg_attribute
|
||||
@@ -380,7 +380,7 @@ func (ss *SqlSupplier) DoesColumnExist(tableName string, columnName string) bool
|
||||
|
||||
return count > 0
|
||||
|
||||
} else if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
} else if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
|
||||
count, err := ss.GetMaster().SelectInt(
|
||||
`SELECT
|
||||
@@ -417,7 +417,7 @@ func (ss *SqlSupplier) CreateColumnIfNotExists(tableName string, columnName stri
|
||||
return false
|
||||
}
|
||||
|
||||
if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
_, err := ss.GetMaster().ExecNoTimeout("ALTER TABLE " + tableName + " ADD " + columnName + " " + postgresColType + " DEFAULT '" + defaultValue + "'")
|
||||
if err != nil {
|
||||
l4g.Critical(utils.T("store.sql.create_column.critical"), err)
|
||||
@@ -427,7 +427,7 @@ func (ss *SqlSupplier) CreateColumnIfNotExists(tableName string, columnName stri
|
||||
|
||||
return true
|
||||
|
||||
} else if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
} else if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
_, err := ss.GetMaster().ExecNoTimeout("ALTER TABLE " + tableName + " ADD " + columnName + " " + mySqlColType + " DEFAULT '" + defaultValue + "'")
|
||||
if err != nil {
|
||||
l4g.Critical(utils.T("store.sql.create_column.critical"), err)
|
||||
@@ -482,9 +482,9 @@ func (ss *SqlSupplier) RenameColumnIfExists(tableName string, oldColumnName stri
|
||||
}
|
||||
|
||||
var err error
|
||||
if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
_, err = ss.GetMaster().ExecNoTimeout("ALTER TABLE " + tableName + " CHANGE " + oldColumnName + " " + newColumnName + " " + colType)
|
||||
} else if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
} else if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
_, err = ss.GetMaster().ExecNoTimeout("ALTER TABLE " + tableName + " RENAME COLUMN " + oldColumnName + " TO " + newColumnName)
|
||||
}
|
||||
|
||||
@@ -504,9 +504,9 @@ func (ss *SqlSupplier) GetMaxLengthOfColumnIfExists(tableName string, columnName
|
||||
|
||||
var result string
|
||||
var err error
|
||||
if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
result, err = ss.GetMaster().SelectStr("SELECT CHARACTER_MAXIMUM_LENGTH FROM information_schema.columns WHERE table_name = '" + tableName + "' AND COLUMN_NAME = '" + columnName + "'")
|
||||
} else if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
} else if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
result, err = ss.GetMaster().SelectStr("SELECT character_maximum_length FROM information_schema.columns WHERE table_name = '" + strings.ToLower(tableName) + "' AND column_name = '" + strings.ToLower(columnName) + "'")
|
||||
}
|
||||
|
||||
@@ -525,9 +525,9 @@ func (ss *SqlSupplier) AlterColumnTypeIfExists(tableName string, columnName stri
|
||||
}
|
||||
|
||||
var err error
|
||||
if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
_, err = ss.GetMaster().ExecNoTimeout("ALTER TABLE " + tableName + " MODIFY " + columnName + " " + mySqlColType)
|
||||
} else if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
} else if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
_, err = ss.GetMaster().ExecNoTimeout("ALTER TABLE " + strings.ToLower(tableName) + " ALTER COLUMN " + strings.ToLower(columnName) + " TYPE " + postgresColType)
|
||||
}
|
||||
|
||||
@@ -559,7 +559,7 @@ func (ss *SqlSupplier) createIndexIfNotExists(indexName string, tableName string
|
||||
uniqueStr = "UNIQUE "
|
||||
}
|
||||
|
||||
if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
_, errExists := ss.GetMaster().SelectStr("SELECT $1::regclass", indexName)
|
||||
// It should fail if the index does not exist
|
||||
if errExists == nil {
|
||||
@@ -581,7 +581,7 @@ func (ss *SqlSupplier) createIndexIfNotExists(indexName string, tableName string
|
||||
time.Sleep(time.Second)
|
||||
os.Exit(EXIT_CREATE_INDEX_POSTGRES)
|
||||
}
|
||||
} else if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
} else if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
|
||||
count, err := ss.GetMaster().SelectInt("SELECT COUNT(0) AS index_exists FROM information_schema.statistics WHERE TABLE_SCHEMA = DATABASE() and table_name = ? AND index_name = ?", tableName, indexName)
|
||||
if err != nil {
|
||||
@@ -616,7 +616,7 @@ func (ss *SqlSupplier) createIndexIfNotExists(indexName string, tableName string
|
||||
|
||||
func (ss *SqlSupplier) RemoveIndexIfExists(indexName string, tableName string) bool {
|
||||
|
||||
if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
_, err := ss.GetMaster().SelectStr("SELECT $1::regclass", indexName)
|
||||
// It should fail if the index does not exist
|
||||
if err != nil {
|
||||
@@ -631,7 +631,7 @@ func (ss *SqlSupplier) RemoveIndexIfExists(indexName string, tableName string) b
|
||||
}
|
||||
|
||||
return true
|
||||
} else if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
} else if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
|
||||
count, err := ss.GetMaster().SelectInt("SELECT COUNT(0) AS index_exists FROM information_schema.statistics WHERE TABLE_SCHEMA = DATABASE() and table_name = ? AND index_name = ?", tableName, indexName)
|
||||
if err != nil {
|
||||
|
||||
@@ -385,7 +385,7 @@ func (s SqlTeamStore) GetAllTeamListing() StoreChannel {
|
||||
|
||||
query := "SELECT * FROM Teams WHERE AllowOpenInvite = 1"
|
||||
|
||||
if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
query = "SELECT * FROM Teams WHERE AllowOpenInvite = true"
|
||||
}
|
||||
|
||||
@@ -417,7 +417,7 @@ func (s SqlTeamStore) GetAllTeamPageListing(offset int, limit int) StoreChannel
|
||||
|
||||
query := "SELECT * FROM Teams WHERE AllowOpenInvite = 1 LIMIT :Limit OFFSET :Offset"
|
||||
|
||||
if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
query = "SELECT * FROM Teams WHERE AllowOpenInvite = true LIMIT :Limit OFFSET :Offset"
|
||||
}
|
||||
|
||||
@@ -506,7 +506,7 @@ func (s SqlTeamStore) SaveMember(member *model.TeamMember) StoreChannel {
|
||||
storeChannel <- result
|
||||
close(storeChannel)
|
||||
return
|
||||
} else if int(count) >= utils.Cfg.TeamSettings.MaxUsersPerTeam {
|
||||
} else if int(count) >= *utils.Cfg.TeamSettings.MaxUsersPerTeam {
|
||||
result.Err = model.NewLocAppError("SqlUserStore.Save", "store.sql_user.save.max_accounts.app_error", nil, "teamId="+member.TeamId)
|
||||
storeChannel <- result
|
||||
close(storeChannel)
|
||||
|
||||
@@ -690,11 +690,11 @@ func TestTeamMembers(t *testing.T) {
|
||||
func TestSaveTeamMemberMaxMembers(t *testing.T) {
|
||||
Setup()
|
||||
|
||||
MaxUsersPerTeam := utils.Cfg.TeamSettings.MaxUsersPerTeam
|
||||
MaxUsersPerTeam := *utils.Cfg.TeamSettings.MaxUsersPerTeam
|
||||
defer func() {
|
||||
utils.Cfg.TeamSettings.MaxUsersPerTeam = MaxUsersPerTeam
|
||||
*utils.Cfg.TeamSettings.MaxUsersPerTeam = MaxUsersPerTeam
|
||||
}()
|
||||
utils.Cfg.TeamSettings.MaxUsersPerTeam = 5
|
||||
*utils.Cfg.TeamSettings.MaxUsersPerTeam = 5
|
||||
|
||||
team := Must(store.Team().Save(&model.Team{
|
||||
DisplayName: "DisplayName",
|
||||
@@ -705,9 +705,9 @@ func TestSaveTeamMemberMaxMembers(t *testing.T) {
|
||||
<-store.Team().PermanentDelete(team.Id)
|
||||
}()
|
||||
|
||||
userIds := make([]string, utils.Cfg.TeamSettings.MaxUsersPerTeam)
|
||||
userIds := make([]string, *utils.Cfg.TeamSettings.MaxUsersPerTeam)
|
||||
|
||||
for i := 0; i < utils.Cfg.TeamSettings.MaxUsersPerTeam; i++ {
|
||||
for i := 0; i < *utils.Cfg.TeamSettings.MaxUsersPerTeam; i++ {
|
||||
userIds[i] = Must(store.User().Save(&model.User{
|
||||
Username: model.NewId(),
|
||||
Email: model.NewId(),
|
||||
@@ -729,7 +729,7 @@ func TestSaveTeamMemberMaxMembers(t *testing.T) {
|
||||
|
||||
if result := <-store.Team().GetTotalMemberCount(team.Id); result.Err != nil {
|
||||
t.Fatal(result.Err)
|
||||
} else if count := result.Data.(int64); int(count) != utils.Cfg.TeamSettings.MaxUsersPerTeam {
|
||||
} else if count := result.Data.(int64); int(count) != *utils.Cfg.TeamSettings.MaxUsersPerTeam {
|
||||
t.Fatalf("should start with 5 team members, had %v instead", count)
|
||||
}
|
||||
|
||||
@@ -750,7 +750,7 @@ func TestSaveTeamMemberMaxMembers(t *testing.T) {
|
||||
|
||||
if result := <-store.Team().GetTotalMemberCount(team.Id); result.Err != nil {
|
||||
t.Fatal(result.Err)
|
||||
} else if count := result.Data.(int64); int(count) != utils.Cfg.TeamSettings.MaxUsersPerTeam {
|
||||
} else if count := result.Data.(int64); int(count) != *utils.Cfg.TeamSettings.MaxUsersPerTeam {
|
||||
t.Fatalf("should still have 5 team members, had %v instead", count)
|
||||
}
|
||||
|
||||
@@ -763,7 +763,7 @@ func TestSaveTeamMemberMaxMembers(t *testing.T) {
|
||||
|
||||
if result := <-store.Team().GetTotalMemberCount(team.Id); result.Err != nil {
|
||||
t.Fatal(result.Err)
|
||||
} else if count := result.Data.(int64); int(count) != utils.Cfg.TeamSettings.MaxUsersPerTeam-1 {
|
||||
} else if count := result.Data.(int64); int(count) != *utils.Cfg.TeamSettings.MaxUsersPerTeam-1 {
|
||||
t.Fatalf("should now only have 4 team members, had %v instead", count)
|
||||
}
|
||||
|
||||
@@ -777,7 +777,7 @@ func TestSaveTeamMemberMaxMembers(t *testing.T) {
|
||||
|
||||
if result := <-store.Team().GetTotalMemberCount(team.Id); result.Err != nil {
|
||||
t.Fatal(result.Err)
|
||||
} else if count := result.Data.(int64); int(count) != utils.Cfg.TeamSettings.MaxUsersPerTeam {
|
||||
} else if count := result.Data.(int64); int(count) != *utils.Cfg.TeamSettings.MaxUsersPerTeam {
|
||||
t.Fatalf("should have 5 team members again, had %v instead", count)
|
||||
}
|
||||
|
||||
|
||||
@@ -131,11 +131,11 @@ func UpgradeDatabaseToVersion33(sqlStore SqlStore) {
|
||||
}
|
||||
|
||||
// increase size of Value column of Preferences table to match the size of the ThemeProps column
|
||||
if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
if _, err := transaction.Exec("ALTER TABLE Preferences ALTER COLUMN Value TYPE varchar(2000)"); err != nil {
|
||||
themeMigrationFailed(err)
|
||||
}
|
||||
} else if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
} else if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
if _, err := transaction.Exec("ALTER TABLE Preferences MODIFY Value text"); err != nil {
|
||||
themeMigrationFailed(err)
|
||||
}
|
||||
|
||||
@@ -101,9 +101,9 @@ func (s SqlUserAccessTokenStore) deleteSessionsAndTokensById(transaction *gorp.T
|
||||
result := StoreResult{}
|
||||
|
||||
query := ""
|
||||
if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
query = "DELETE FROM Sessions s USING UserAccessTokens o WHERE o.Token = s.Token AND o.Id = :Id"
|
||||
} else if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
} else if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
query = "DELETE s.* FROM Sessions s INNER JOIN UserAccessTokens o ON o.Token = s.Token WHERE o.Id = :Id"
|
||||
}
|
||||
|
||||
@@ -163,9 +163,9 @@ func (s SqlUserAccessTokenStore) deleteSessionsandTokensByUser(transaction *gorp
|
||||
result := StoreResult{}
|
||||
|
||||
query := ""
|
||||
if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
query = "DELETE FROM Sessions s USING UserAccessTokens o WHERE o.Token = s.Token AND o.UserId = :UserId"
|
||||
} else if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
} else if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
query = "DELETE s.* FROM Sessions s INNER JOIN UserAccessTokens o ON o.Token = s.Token WHERE o.UserId = :UserId"
|
||||
}
|
||||
|
||||
|
||||
@@ -1431,9 +1431,9 @@ func (us SqlUserStore) performSearch(searchQuery string, term string, options ma
|
||||
originalTerm := term
|
||||
postgresUseOriginalTerm := false
|
||||
if strings.Contains(term, "@") && strings.Contains(term, ".") {
|
||||
if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
postgresUseOriginalTerm = true
|
||||
} else if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
} else if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
lastIndex := strings.LastIndex(term, ".")
|
||||
term = term[0:lastIndex]
|
||||
}
|
||||
@@ -1461,7 +1461,7 @@ func (us SqlUserStore) performSearch(searchQuery string, term string, options ma
|
||||
|
||||
if term == "" {
|
||||
searchQuery = strings.Replace(searchQuery, "SEARCH_CLAUSE", "", 1)
|
||||
} else if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
} else if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
||||
if postgresUseOriginalTerm {
|
||||
term = originalTerm
|
||||
// these chars will break the query and must be removed
|
||||
@@ -1484,7 +1484,7 @@ func (us SqlUserStore) performSearch(searchQuery string, term string, options ma
|
||||
searchType = convertMySQLFullTextColumnsToPostgres(searchType)
|
||||
searchClause := fmt.Sprintf("AND (%s) @@ to_tsquery('simple', :Term)", searchType)
|
||||
searchQuery = strings.Replace(searchQuery, "SEARCH_CLAUSE", searchClause, 1)
|
||||
} else if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
} else if *utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
|
||||
splitTerm := strings.Fields(term)
|
||||
for i, t := range strings.Fields(term) {
|
||||
splitTerm[i] = "+" + t + "*"
|
||||
|
||||
Ссылка в новой задаче
Block a user