forked from GoAdminGroup/go-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
postgresql.go
31 lines (25 loc) · 860 Bytes
/
postgresql.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright 2019 GoAdmin Core Team. All rights reserved.
// Use of this source code is governed by a Apache-2.0 style
// license that can be found in the LICENSE file.
package dialect
import (
"fmt"
"strings"
)
type postgresql struct {
commonDialect
}
func (postgresql) GetName() string {
return "postgresql"
}
func (postgresql) ShowTables() string {
return "SELECT tablename FROM pg_catalog.pg_tables WHERE schemaname != 'pg_catalog' AND schemaname != 'information_schema';"
}
func (postgresql) ShowColumns(table string) string {
tableArr := strings.Split(table, "\".\"")
if len(tableArr) > 1 {
return fmt.Sprintf("select * from information_schema.columns where table_name = '%s' and table_schema = '%s'", tableArr[1], tableArr[0])
} else {
return fmt.Sprintf("select * from information_schema.columns where table_name = '%s'", table)
}
}