Skip to content

Commit 3c891f0

Browse files
committed
fix: fix query for buildQueryUniqueKeys
Signed-off-by: Muhammad Aaqil <[email protected]>
1 parent 31c0725 commit 3c891f0

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

lib/discovery.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -348,17 +348,17 @@ function mixinDiscovery(PostgreSQL) {
348348
* @returns {string}
349349
*/
350350
PostgreSQL.prototype.buildQueryUniqueKeys = function(schema, table) {
351-
const sql = 'SELECT a.attname AS "columnName", n.nspname AS "owner", c.relname AS "tableName"'
352-
+ 'FROM pg_index i'
353-
+ 'JOIN pg_class c ON c.oid = i.indrelid'
354-
+ 'JOIN pg_namespace n ON n.oid = c.relnamespace'
355-
+ 'JOIN pg_attribute a ON a.attrelid = c.oid AND a.attnum = ANY(i.indkey)'
356-
+ 'WHERE i.indisunique = true'
357-
+ 'AND i.indisprimary = false'
358-
+ 'AND n.nspname = $1'
359-
+ 'AND c.relname = $2'
351+
const sql = 'SELECT a.attname AS "columnName", n.nspname AS "owner", c.relname AS "tableName" '
352+
+ 'FROM pg_index i '
353+
+ 'JOIN pg_class c ON c.oid = i.indrelid '
354+
+ 'JOIN pg_namespace n ON n.oid = c.relnamespace '
355+
+ 'JOIN pg_attribute a ON a.attrelid = c.oid AND a.attnum = ANY(i.indkey) '
356+
+ 'WHERE i.indisunique = true '
357+
+ 'AND i.indisprimary = false '
358+
+ 'AND n.nspname = \'' + schema + '\' '
359+
+ 'AND c.relname = \'' + table + '\' '
360360
+ 'ORDER BY a.attnum';
361-
return {text: sql, values: [schema, table]};
361+
return sql;
362362
};
363363

364364
/**

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"bluebird": "^3.4.6",
3434
"chalk": "^4.0.0",
3535
"debug": "^4.1.1",
36-
"loopback-connector": "^6.0.0",
36+
"loopback-connector": "^6.2.1",
3737
"pg": "^8.0.2",
3838
"strong-globalize": "^6.0.0",
3939
"uuid": "^11.0.0"

0 commit comments

Comments
 (0)