Change static queries prefix to PG_
This commit is contained in:
parent
e016e7a8d2
commit
32d7bf864f
4
api.go
4
api.go
@ -68,7 +68,7 @@ func API_GetTables(c *gin.Context) {
|
||||
}
|
||||
|
||||
func API_GetTable(c *gin.Context) {
|
||||
res, err := dbClient.Query(fmt.Sprintf(SQL_TABLE_SCHEMA, c.Params.ByName("table")))
|
||||
res, err := dbClient.Query(fmt.Sprintf(PG_TABLE_SCHEMA, c.Params.ByName("table")))
|
||||
|
||||
if err != nil {
|
||||
c.JSON(400, NewError(err))
|
||||
@ -83,7 +83,7 @@ func API_History(c *gin.Context) {
|
||||
}
|
||||
|
||||
func API_Info(c *gin.Context) {
|
||||
res, err := dbClient.Query(SQL_INFO)
|
||||
res, err := dbClient.Query(PG_INFO)
|
||||
|
||||
if err != nil {
|
||||
c.JSON(400, NewError(err))
|
||||
|
12
client.go
12
client.go
@ -9,10 +9,10 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
SQL_INFO = "SELECT version(), user, current_database(), inet_client_addr(), inet_client_port(), inet_server_addr(), inet_server_port()"
|
||||
SQL_TABLES = "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' ORDER BY table_schema,table_name;"
|
||||
SQL_TABLE_SCHEMA = "SELECT column_name, data_type, is_nullable, character_maximum_length, character_set_catalog, column_default FROM information_schema.columns where table_name = '%s';"
|
||||
SQL_TABLE_INDEXES = "SELECT indexname, indexdef FROM pg_indexes WHERE tablename = '%s';"
|
||||
PG_INFO = "SELECT version(), user, current_database(), inet_client_addr(), inet_client_port(), inet_server_addr(), inet_server_port()"
|
||||
PG_TABLES = "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' ORDER BY table_schema,table_name;"
|
||||
PG_TABLE_SCHEMA = "SELECT column_name, data_type, is_nullable, character_maximum_length, character_set_catalog, column_default FROM information_schema.columns where table_name = '%s';"
|
||||
PG_TABLE_INDEXES = "SELECT indexname, indexdef FROM pg_indexes WHERE tablename = '%s';"
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
@ -48,7 +48,7 @@ func (client *Client) recordQuery(query string) {
|
||||
}
|
||||
|
||||
func (client *Client) Tables() ([]string, error) {
|
||||
res, err := client.Query(SQL_TABLES)
|
||||
res, err := client.Query(PG_TABLES)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -64,7 +64,7 @@ func (client *Client) Tables() ([]string, error) {
|
||||
}
|
||||
|
||||
func (client *Client) TableIndexes(table string) (*Result, error) {
|
||||
res, err := client.Query(fmt.Sprintf(SQL_TABLE_INDEXES, table))
|
||||
res, err := client.Query(fmt.Sprintf(PG_TABLE_INDEXES, table))
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Loading…
x
Reference in New Issue
Block a user