@budibase/server 2.6.19-alpha.2 → 2.6.19-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@
8
8
  <link rel="preconnect" href="https://fonts.gstatic.com" />
9
9
  <link href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@400;600;700&display=swap"
10
10
  rel="stylesheet" />
11
- <script type="module" crossorigin src="/builder/assets/index.6c1171e2.js"></script>
11
+ <script type="module" crossorigin src="/builder/assets/index.71388c79.js"></script>
12
12
  <link rel="stylesheet" href="/builder/assets/index.07382a47.css">
13
13
  </head>
14
14
 
@@ -101,14 +101,15 @@ class PostgresIntegration extends sql_1.default {
101
101
  this.index = 1;
102
102
  this.tables = {};
103
103
  this.schemaErrors = {};
104
- this.PRIMARY_KEYS_SQL = `
105
- select tc.table_schema, tc.table_name, kc.column_name as primary_key
106
- from information_schema.table_constraints tc
107
- join
108
- information_schema.key_column_usage kc on kc.table_name = tc.table_name
109
- and kc.table_schema = tc.table_schema
110
- and kc.constraint_name = tc.constraint_name
111
- where tc.constraint_type = 'PRIMARY KEY';
104
+ this.PRIMARY_KEYS_SQL = () => `
105
+ SELECT pg_namespace.nspname table_schema
106
+ , pg_class.relname table_name
107
+ , pg_attribute.attname primary_key
108
+ FROM pg_class
109
+ JOIN pg_index ON pg_class.oid = pg_index.indrelid AND pg_index.indisprimary
110
+ JOIN pg_attribute ON pg_attribute.attrelid = pg_class.oid AND pg_attribute.attnum = ANY(pg_index.indkey)
111
+ JOIN pg_namespace ON pg_namespace.oid = pg_class.relnamespace
112
+ WHERE pg_namespace.nspname = '${this.config.schema}';
112
113
  `;
113
114
  this.config = config;
114
115
  let newConfig = Object.assign(Object.assign({}, this.config), { ssl: this.config.ssl
@@ -212,7 +213,7 @@ class PostgresIntegration extends sql_1.default {
212
213
  let tableKeys = {};
213
214
  yield this.openConnection();
214
215
  try {
215
- const primaryKeysResponse = yield this.client.query(this.PRIMARY_KEYS_SQL);
216
+ const primaryKeysResponse = yield this.client.query(this.PRIMARY_KEYS_SQL());
216
217
  for (let table of primaryKeysResponse.rows) {
217
218
  const tableName = table.table_name;
218
219
  if (!tableKeys[tableName]) {