1
0
mirror of https://github.com/mattermost/focalboard.git synced 2024-11-24 08:22:29 +02:00

Merge from main

This commit is contained in:
Chen-I Lim 2020-10-14 12:51:37 -07:00
parent ef8c9ceccd
commit 94cc769d4b
2 changed files with 5 additions and 4 deletions

View File

@ -19,7 +19,7 @@ import (
"github.com/gorilla/mux"
)
var config Configuration
var config *Configuration
var wsServer *WSServer
var store *SQLStore
@ -376,7 +376,6 @@ func main() {
http.Handle("/", r)
var err error
store, err = NewSQLStore(config.DBType, config.DBConfigString)
if err != nil {
log.Fatal("Unable to start the database", err)

View File

@ -10,11 +10,13 @@ import (
_ "github.com/mattn/go-sqlite3"
)
// SQLStore is a SQL database
type SQLStore struct {
db *sql.DB
dbType string
}
// NewSQLStore creates a new SQLStore
func NewSQLStore(dbType, connectionString string) (*SQLStore, error) {
log.Println("connectDatabase")
var err error
@ -149,7 +151,7 @@ func (s *SQLStore) getBlocksWithParent(parentID string) []string {
return blocksFromRows(rows)
}
func (s *SQLStore) getBlocksWithType(blockID string) []string {
func (s *SQLStore) getBlocksWithType(blockType string) []string {
query := `WITH latest AS
(
SELECT * FROM
@ -166,7 +168,7 @@ func (s *SQLStore) getBlocksWithType(blockID string) []string {
FROM latest
WHERE delete_at = 0 and type = $1`
rows, err := db.Query(query, blockType)
rows, err := s.db.Query(query, blockType)
if err != nil {
log.Printf(`getBlocksWithParentAndType ERROR: %v`, err)
panic(err)