mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-06-11 09:00:00 +08:00
🐛 fix(postgres): 修复 LIKE 'pg_%' 误匹配 pgsrpschema 等非系统 schema
LIKE 模式中 '_' 是单字符通配符,'pg_%' 不仅匹配 pg_catalog/pg_toast, 还会匹配 pgsrpschema 等以 'pgs' 开头的 schema,导致这些 schema 下的表被 GetTables 漏掉,侧边栏不显示 schema 分组。 改用 LIKE 'pg|_%' ESCAPE '|','_' 仅匹配字面量下划线。
This commit is contained in:
@@ -285,7 +285,7 @@ func (p *PostgresDB) GetDatabases() ([]string, error) {
|
||||
}
|
||||
|
||||
func (p *PostgresDB) GetTables(dbName string) ([]string, error) {
|
||||
query := "SELECT schemaname, tablename FROM pg_catalog.pg_tables WHERE schemaname != 'information_schema' AND schemaname NOT LIKE 'pg_%' ORDER BY schemaname, tablename"
|
||||
query := "SELECT schemaname, tablename FROM pg_catalog.pg_tables WHERE schemaname != 'information_schema' AND schemaname NOT LIKE 'pg|_%' ESCAPE '|' ORDER BY schemaname, tablename"
|
||||
data, _, err := p.Query(query)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -594,7 +594,7 @@ func (p *PostgresDB) GetAllColumns(dbName string) ([]connection.ColumnDefinition
|
||||
SELECT table_schema, table_name, column_name, data_type
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema NOT IN ('pg_catalog', 'information_schema')
|
||||
AND table_schema NOT LIKE 'pg_%'
|
||||
AND table_schema NOT LIKE 'pg|_%' ESCAPE '|'
|
||||
ORDER BY table_schema, table_name, ordinal_position`
|
||||
|
||||
data, _, err := p.Query(query)
|
||||
@@ -692,7 +692,7 @@ func (p *PostgresDB) queryUserSchemas() []string {
|
||||
|
||||
query := `SELECT nspname FROM pg_namespace
|
||||
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
|
||||
AND nspname NOT LIKE 'pg_%'
|
||||
AND nspname NOT LIKE 'pg|_%' ESCAPE '|'
|
||||
ORDER BY nspname`
|
||||
|
||||
rows, err := p.conn.Query(query)
|
||||
|
||||
Reference in New Issue
Block a user