use a different query to fetch materialized view structure
This commit is contained in:
@@ -151,7 +151,15 @@ func GetSchemas(c *gin.Context) {
|
||||
}
|
||||
|
||||
func GetTable(c *gin.Context) {
|
||||
res, err := DB(c).Table(c.Params.ByName("table"))
|
||||
var res *client.Result
|
||||
var err error
|
||||
|
||||
if c.Request.FormValue("type") == "materialized_view" {
|
||||
res, err = DB(c).MaterializedView(c.Params.ByName("table"))
|
||||
} else {
|
||||
res, err = DB(c).Table(c.Params.ByName("table"))
|
||||
}
|
||||
|
||||
serveResult(res, err, c)
|
||||
}
|
||||
|
||||
|
||||
@@ -107,6 +107,10 @@ func (client *Client) Table(table string) (*Result, error) {
|
||||
return client.query(statements.PG_TABLE_SCHEMA, schema, table)
|
||||
}
|
||||
|
||||
func (client *Client) MaterializedView(name string) (*Result, error) {
|
||||
return client.query(statements.PG_MATERIALIZED_VIEW_SCHEMA, name)
|
||||
}
|
||||
|
||||
func (client *Client) TableRows(table string, opts RowsOptions) (*Result, error) {
|
||||
schema, table := getSchemaAndTable(table)
|
||||
sql := fmt.Sprintf(`SELECT * FROM "%s"."%s"`, schema, table)
|
||||
|
||||
@@ -25,10 +25,10 @@ type Result struct {
|
||||
}
|
||||
|
||||
type Objects struct {
|
||||
Tables []string `json:"tables"`
|
||||
Views []string `json:"views"`
|
||||
MaterializedViews []string `json:"materialized_views"`
|
||||
Sequences []string `json:"sequences"`
|
||||
Tables []string `json:"table"`
|
||||
Views []string `json:"view"`
|
||||
MaterializedViews []string `json:"materialized_view"`
|
||||
Sequences []string `json:"sequence"`
|
||||
}
|
||||
|
||||
// Due to big int number limitations in javascript, numbers should be encoded
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -92,6 +92,23 @@ WHERE
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
PG_MATERIALIZED_VIEW_SCHEMA = `
|
||||
SELECT
|
||||
attname as column_name,
|
||||
atttypid::regtype AS data_type,
|
||||
(case when attnotnull IS TRUE then 'NO' else 'YES' end) as is_nullable,
|
||||
null as character_maximum_length,
|
||||
null as character_set_catalog,
|
||||
null as column_default
|
||||
FROM
|
||||
pg_attribute
|
||||
WHERE
|
||||
attrelid = $1::regclass AND
|
||||
attnum > 0 AND
|
||||
NOT attisdropped`
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
PG_ACTIVITY = `
|
||||
SELECT
|
||||
datname,
|
||||
|
||||
Reference in New Issue
Block a user