|
|
|
@ -28,6 +28,7 @@ module PostgresModule { |
|
|
|
database: string |
|
|
|
user: string |
|
|
|
password: string |
|
|
|
schema: string |
|
|
|
ssl?: boolean |
|
|
|
ca?: string |
|
|
|
rejectUnauthorized?: boolean |
|
|
|
@ -65,6 +66,11 @@ module PostgresModule { |
|
|
|
default: "root", |
|
|
|
required: true, |
|
|
|
}, |
|
|
|
schema: { |
|
|
|
type: DatasourceFieldTypes.STRING, |
|
|
|
default: "public", |
|
|
|
required: true, |
|
|
|
}, |
|
|
|
ssl: { |
|
|
|
type: DatasourceFieldTypes.BOOLEAN, |
|
|
|
default: false, |
|
|
|
@ -124,8 +130,7 @@ module PostgresModule { |
|
|
|
public tables: Record<string, Table> = {} |
|
|
|
public schemaErrors: Record<string, string> = {} |
|
|
|
|
|
|
|
COLUMNS_SQL = |
|
|
|
"select * from information_schema.columns where not table_schema = 'information_schema' and not table_schema = 'pg_catalog'" |
|
|
|
COLUMNS_SQL!: string |
|
|
|
|
|
|
|
PRIMARY_KEYS_SQL = ` |
|
|
|
select tc.table_schema, tc.table_name, kc.column_name as primary_key |
|
|
|
@ -155,6 +160,17 @@ module PostgresModule { |
|
|
|
} |
|
|
|
|
|
|
|
this.client = this.pool |
|
|
|
this.setSchema() |
|
|
|
} |
|
|
|
|
|
|
|
setSchema() { |
|
|
|
if (!this.config.schema) { |
|
|
|
this.config.schema = 'public' |
|
|
|
} |
|
|
|
this.client.on('connect', (client: any) => { |
|
|
|
client.query(`SET search_path TO ${this.config.schema}`); |
|
|
|
}); |
|
|
|
this.COLUMNS_SQL = `select * from information_schema.columns where table_schema = '${this.config.schema}'` |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
|