* Revert "Revert "[MM-62142] Avoid SELECT * in status_store.go (#29610)" (#29985)"
This reverts commit d345e92136.
* add tests for StatusGet and StatusGetByIds
* handle NULL columns in the Status Store
* simplify status store
* more builder simplifications and tests
* expose GetQueryPlaceholder
---------
Co-authored-by: Mattermost Build <build@mattermost.com>
37 строки
921 B
Go
37 строки
921 B
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package storetest
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/mattermost/mattermost/server/public/model"
|
|
)
|
|
|
|
// This function has a copy of it in app/helper_test
|
|
// NewTestID is used for testing as a replacement for model.NewId(). It is a [A-Z0-9] string 26
|
|
// characters long. It replaces every odd character with a digit.
|
|
func NewTestID() string {
|
|
newID := []byte(model.NewId())
|
|
|
|
for i := 1; i < len(newID); i = i + 2 {
|
|
newID[i] = 48 + newID[i-1]%10
|
|
}
|
|
|
|
return string(newID)
|
|
}
|
|
|
|
// Adds backtiks to the column name for MySQL, this is required if
|
|
// the column name is a reserved keyword.
|
|
//
|
|
// `ColumnName` - MySQL
|
|
// ColumnName - Postgres
|
|
func quoteColumnName(driver string, columnName string) string {
|
|
if driver == model.DatabaseDriverMysql {
|
|
return fmt.Sprintf("`%s`", columnName)
|
|
}
|
|
|
|
return columnName
|
|
}
|