@malloydata/db-postgres 0.0.49-dev230626172855 → 0.0.49-dev230626192330
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.
|
@@ -26,7 +26,7 @@ export declare class PostgresConnection implements Connection, StreamingConnecti
|
|
|
26
26
|
isPool(): this is PooledConnection;
|
|
27
27
|
canPersist(): this is PersistSQLResults;
|
|
28
28
|
canStream(): this is StreamingConnection;
|
|
29
|
-
fetchSchemaForTables(missing: string
|
|
29
|
+
fetchSchemaForTables(missing: Record<string, string>): Promise<{
|
|
30
30
|
schemas: Record<string, StructDef>;
|
|
31
31
|
errors: Record<string, string>;
|
|
32
32
|
}>;
|
|
@@ -55,7 +55,6 @@ exports.PooledPostgresConnection = exports.PostgresConnection = void 0;
|
|
|
55
55
|
// create extension if not exists tsm_system_rows
|
|
56
56
|
//
|
|
57
57
|
const crypto = __importStar(require("crypto"));
|
|
58
|
-
const malloy_1 = require("@malloydata/malloy");
|
|
59
58
|
const pg_1 = require("pg");
|
|
60
59
|
const pg_query_stream_1 = __importDefault(require("pg-query-stream"));
|
|
61
60
|
const crypto_1 = require("crypto");
|
|
@@ -126,24 +125,25 @@ class PostgresConnection {
|
|
|
126
125
|
async fetchSchemaForTables(missing) {
|
|
127
126
|
const schemas = {};
|
|
128
127
|
const errors = {};
|
|
129
|
-
for (const
|
|
130
|
-
let inCache = this.schemaCache.get(
|
|
128
|
+
for (const tableKey in missing) {
|
|
129
|
+
let inCache = this.schemaCache.get(tableKey);
|
|
131
130
|
if (!inCache) {
|
|
131
|
+
const tablePath = missing[tableKey];
|
|
132
132
|
try {
|
|
133
133
|
inCache = {
|
|
134
|
-
schema: await this.getTableSchema(
|
|
134
|
+
schema: await this.getTableSchema(tableKey, tablePath),
|
|
135
135
|
};
|
|
136
|
-
this.schemaCache.set(
|
|
136
|
+
this.schemaCache.set(tableKey, inCache);
|
|
137
137
|
}
|
|
138
138
|
catch (error) {
|
|
139
139
|
inCache = { error: error.message };
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
if (inCache.schema !== undefined) {
|
|
143
|
-
schemas[
|
|
143
|
+
schemas[tableKey] = inCache.schema;
|
|
144
144
|
}
|
|
145
145
|
else {
|
|
146
|
-
errors[
|
|
146
|
+
errors[tableKey] = inCache.error || 'Unknown schema fetch error';
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
return { schemas, errors };
|
|
@@ -260,11 +260,10 @@ class PostgresConnection {
|
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
|
-
async getTableSchema(
|
|
264
|
-
const { tablePath } = (0, malloy_1.parseTableURI)(tableURL);
|
|
263
|
+
async getTableSchema(tableKey, tablePath) {
|
|
265
264
|
const structDef = {
|
|
266
265
|
type: 'struct',
|
|
267
|
-
name:
|
|
266
|
+
name: tableKey,
|
|
268
267
|
dialect: 'postgres',
|
|
269
268
|
structSource: { type: 'table', tablePath },
|
|
270
269
|
structRelationship: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/db-postgres",
|
|
3
|
-
"version": "0.0.49-
|
|
3
|
+
"version": "0.0.49-dev230626192330",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"prepublishOnly": "npm run build"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@malloydata/malloy": "^0.0.49-
|
|
22
|
+
"@malloydata/malloy": "^0.0.49-dev230626192330",
|
|
23
23
|
"@types/pg": "^8.6.1",
|
|
24
24
|
"pg": "^8.7.1",
|
|
25
25
|
"pg-query-stream": "4.2.3"
|