From 7b092fe972585c97d890fd98a3e8a9e4b567bec1 Mon Sep 17 00:00:00 2001 From: Basit Mustafa Date: Thu, 11 Aug 2022 18:21:22 -0600 Subject: [PATCH 1/2] fix(postgres): double quote identifiers This fixes an issue related to not being able to use any relation name that is not fully lowercase --- lib/postgres/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/postgres/script.js b/lib/postgres/script.js index 337b7d9..b967475 100644 --- a/lib/postgres/script.js +++ b/lib/postgres/script.js @@ -63,7 +63,7 @@ class Script extends Postgres { return; if (!this.buffer) - this.buffer = `${this.prefix} ${this.schema}.${this.table} ( ${columns.map(quoteString).join(',')} ) VALUES `; + this.buffer = `${this.prefix} "${this.schema}"."${this.table}" ( ${columns.map(quoteString).join(',')} ) VALUES `; else this.buffer += ', '; From aec2195dee4bc66b63d0be5bec5a4aefd8f5746e Mon Sep 17 00:00:00 2001 From: Basit Mustafa Date: Thu, 11 Aug 2022 18:48:59 -0600 Subject: [PATCH 2/2] fix(postgres): properly quote identifiers --- lib/postgres/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/postgres/script.js b/lib/postgres/script.js index b967475..5bc4188 100644 --- a/lib/postgres/script.js +++ b/lib/postgres/script.js @@ -33,7 +33,7 @@ class Script extends Postgres { ' FROM pg_index i' + ' JOIN pg_attribute a ON a.attrelid = i.indrelid' + ' AND a.attnum = ANY(i.indkey)' + - ` WHERE i.indrelid = '${this.schema}.${this.table}'::regclass` + + ` WHERE i.indrelid = '"${this.schema}"."${this.table}"'::regclass` + ' AND i.indisprimary;'; return this.query(sql)