Lint: Fix sql statements naming
This commit is contained in:
parent
9430d734a7
commit
1f39c2e229
@ -121,28 +121,28 @@ func (client *Client) Test() error {
|
||||
}
|
||||
|
||||
func (client *Client) Info() (*Result, error) {
|
||||
return client.query(statements.PG_INFO)
|
||||
return client.query(statements.Info)
|
||||
}
|
||||
|
||||
func (client *Client) Databases() ([]string, error) {
|
||||
return client.fetchRows(statements.PG_DATABASES)
|
||||
return client.fetchRows(statements.Databases)
|
||||
}
|
||||
|
||||
func (client *Client) Schemas() ([]string, error) {
|
||||
return client.fetchRows(statements.PG_SCHEMAS)
|
||||
return client.fetchRows(statements.Schemas)
|
||||
}
|
||||
|
||||
func (client *Client) Objects() (*Result, error) {
|
||||
return client.query(statements.PG_OBJECTS)
|
||||
return client.query(statements.Objects)
|
||||
}
|
||||
|
||||
func (client *Client) Table(table string) (*Result, error) {
|
||||
schema, table := getSchemaAndTable(table)
|
||||
return client.query(statements.PG_TABLE_SCHEMA, schema, table)
|
||||
return client.query(statements.TableSchema, schema, table)
|
||||
}
|
||||
|
||||
func (client *Client) MaterializedView(name string) (*Result, error) {
|
||||
return client.query(statements.PG_MATERIALIZED_VIEW_SCHEMA, name)
|
||||
return client.query(statements.MaterializedView, name)
|
||||
}
|
||||
|
||||
func (client *Client) TableRows(table string, opts RowsOptions) (*Result, error) {
|
||||
@ -184,12 +184,12 @@ func (client *Client) TableRowsCount(table string, opts RowsOptions) (*Result, e
|
||||
}
|
||||
|
||||
func (client *Client) TableInfo(table string) (*Result, error) {
|
||||
return client.query(statements.PG_TABLE_INFO, table)
|
||||
return client.query(statements.TableInfo, table)
|
||||
}
|
||||
|
||||
func (client *Client) TableIndexes(table string) (*Result, error) {
|
||||
schema, table := getSchemaAndTable(table)
|
||||
res, err := client.query(statements.PG_TABLE_INDEXES, schema, table)
|
||||
res, err := client.query(statements.TableIndexes, schema, table)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -200,7 +200,7 @@ func (client *Client) TableIndexes(table string) (*Result, error) {
|
||||
|
||||
func (client *Client) TableConstraints(table string) (*Result, error) {
|
||||
schema, table := getSchemaAndTable(table)
|
||||
res, err := client.query(statements.PG_TABLE_CONSTRAINTS, schema, table)
|
||||
res, err := client.query(statements.TableConstraints, schema, table)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -211,7 +211,7 @@ func (client *Client) TableConstraints(table string) (*Result, error) {
|
||||
|
||||
// Returns all active queriers on the server
|
||||
func (client *Client) Activity() (*Result, error) {
|
||||
return client.query(statements.PG_ACTIVITY)
|
||||
return client.query(statements.Activity)
|
||||
}
|
||||
|
||||
func (client *Client) Query(query string) (*Result, error) {
|
||||
|
@ -1,9 +1,7 @@
|
||||
package statements
|
||||
|
||||
const (
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
PG_DATABASES = `
|
||||
Databases = `
|
||||
SELECT
|
||||
datname
|
||||
FROM
|
||||
@ -15,7 +13,7 @@ ORDER BY
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
PG_SCHEMAS = `
|
||||
Schemas = `
|
||||
SELECT
|
||||
schema_name
|
||||
FROM
|
||||
@ -25,7 +23,7 @@ ORDER BY
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
PG_INFO = `
|
||||
Info = `
|
||||
SELECT
|
||||
session_user,
|
||||
current_user,
|
||||
@ -39,7 +37,7 @@ SELECT
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
PG_TABLE_INDEXES = `
|
||||
TableIndexes = `
|
||||
SELECT
|
||||
indexname, indexdef
|
||||
FROM
|
||||
@ -50,7 +48,7 @@ WHERE
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
PG_TABLE_CONSTRAINTS = `
|
||||
TableConstraints = `
|
||||
SELECT
|
||||
pg_get_constraintdef(c.oid, true) as condef
|
||||
FROM
|
||||
@ -67,7 +65,7 @@ ORDER BY
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
PG_TABLE_INFO = `
|
||||
TableInfo = `
|
||||
SELECT
|
||||
pg_size_pretty(pg_table_size($1)) AS data_size,
|
||||
pg_size_pretty(pg_indexes_size($1)) AS index_size,
|
||||
@ -76,7 +74,7 @@ SELECT
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
PG_TABLE_SCHEMA = `
|
||||
TableSchema = `
|
||||
SELECT
|
||||
column_name,
|
||||
data_type,
|
||||
@ -92,7 +90,7 @@ WHERE
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
PG_MATERIALIZED_VIEW_SCHEMA = `
|
||||
MaterializedView = `
|
||||
SELECT
|
||||
attname as column_name,
|
||||
atttypid::regtype AS data_type,
|
||||
@ -109,7 +107,7 @@ WHERE
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
PG_ACTIVITY = `
|
||||
Activity = `
|
||||
SELECT
|
||||
datname,
|
||||
query,
|
||||
@ -128,7 +126,7 @@ WHERE
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
PG_OBJECTS = `
|
||||
Objects = `
|
||||
SELECT
|
||||
n.nspname as "schema",
|
||||
c.relname as "name",
|
||||
|
Loading…
x
Reference in New Issue
Block a user