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