Fixing an issue with typing in the information_schema table that was leading to an 'invalid syntax name' message when attempting to fetch tables from our QA postgres database.
This commit is contained in:
parent
d93e75ce18
commit
82ba1df4ef
|
@ -149,8 +149,6 @@ class PostgresIntegration extends Sql implements DatasourcePlus {
|
||||||
private index: number = 1
|
private index: number = 1
|
||||||
private open: boolean
|
private open: boolean
|
||||||
|
|
||||||
COLUMNS_SQL!: string
|
|
||||||
|
|
||||||
PRIMARY_KEYS_SQL = () => `
|
PRIMARY_KEYS_SQL = () => `
|
||||||
SELECT pg_namespace.nspname table_schema
|
SELECT pg_namespace.nspname table_schema
|
||||||
, pg_class.relname table_name
|
, pg_class.relname table_name
|
||||||
|
@ -171,6 +169,11 @@ class PostgresIntegration extends Sql implements DatasourcePlus {
|
||||||
JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace;
|
JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace;
|
||||||
`
|
`
|
||||||
|
|
||||||
|
COLUMNS_SQL = () => `
|
||||||
|
select * from information_schema.columns where table_schema = ANY(current_schemas(false))
|
||||||
|
AND pg_table_is_visible(to_regclass(format('%I.%I', table_schema, table_name)));
|
||||||
|
`
|
||||||
|
|
||||||
constructor(config: PostgresConfig) {
|
constructor(config: PostgresConfig) {
|
||||||
super(SqlClient.POSTGRES)
|
super(SqlClient.POSTGRES)
|
||||||
this.config = config
|
this.config = config
|
||||||
|
@ -224,8 +227,6 @@ class PostgresIntegration extends Sql implements DatasourcePlus {
|
||||||
.split(",")
|
.split(",")
|
||||||
.map(item => `"${item.trim()}"`)
|
.map(item => `"${item.trim()}"`)
|
||||||
await this.client.query(`SET search_path TO ${search_path.join(",")};`)
|
await this.client.query(`SET search_path TO ${search_path.join(",")};`)
|
||||||
this.COLUMNS_SQL = `select * from information_schema.columns where table_schema = ANY(current_schemas(false))
|
|
||||||
AND pg_table_is_visible(to_regclass(table_schema || '.' || table_name));`
|
|
||||||
this.open = true
|
this.open = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,7 +313,7 @@ class PostgresIntegration extends Sql implements DatasourcePlus {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const columnsResponse: { rows: PostgresColumn[] } =
|
const columnsResponse: { rows: PostgresColumn[] } =
|
||||||
await this.client.query(this.COLUMNS_SQL)
|
await this.client.query(this.COLUMNS_SQL())
|
||||||
|
|
||||||
const tables: { [key: string]: Table } = {}
|
const tables: { [key: string]: Table } = {}
|
||||||
|
|
||||||
|
@ -382,7 +383,7 @@ class PostgresIntegration extends Sql implements DatasourcePlus {
|
||||||
try {
|
try {
|
||||||
await this.openConnection()
|
await this.openConnection()
|
||||||
const columnsResponse: { rows: PostgresColumn[] } =
|
const columnsResponse: { rows: PostgresColumn[] } =
|
||||||
await this.client.query(this.COLUMNS_SQL)
|
await this.client.query(this.COLUMNS_SQL())
|
||||||
const names = columnsResponse.rows.map(row => row.table_name)
|
const names = columnsResponse.rows.map(row => row.table_name)
|
||||||
return [...new Set(names)]
|
return [...new Set(names)]
|
||||||
} finally {
|
} finally {
|
||||||
|
|
Loading…
Reference in New Issue