@malloydata/db-postgres 0.0.100 → 0.0.101-dev231107220340
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.
- package/dist/postgres_connection.js +17 -4
- package/package.json +3 -3
|
@@ -207,12 +207,20 @@ class PostgresConnection {
|
|
|
207
207
|
= (e.object_catalog, e.object_schema, e.object_name, e.object_type, e.collection_type_identifier))
|
|
208
208
|
where table_name='${tempTableName}';
|
|
209
209
|
`;
|
|
210
|
-
|
|
210
|
+
try {
|
|
211
|
+
await this.schemaFromQuery(infoQuery, structDef);
|
|
212
|
+
}
|
|
213
|
+
catch (error) {
|
|
214
|
+
throw new Error(`Error fetching schema for ${sqlRef.name}: ${error}`);
|
|
215
|
+
}
|
|
211
216
|
return structDef;
|
|
212
217
|
}
|
|
213
218
|
async schemaFromQuery(infoQuery, structDef) {
|
|
214
|
-
const
|
|
215
|
-
|
|
219
|
+
const { rows, totalRows } = await this.runPostgresQuery(infoQuery, SCHEMA_PAGE_SIZE, 0, false);
|
|
220
|
+
if (!totalRows) {
|
|
221
|
+
throw new Error('Unable to read schema.');
|
|
222
|
+
}
|
|
223
|
+
for (const row of rows) {
|
|
216
224
|
const postgresDataType = row['data_type'];
|
|
217
225
|
let s = structDef;
|
|
218
226
|
let malloyType = this.dialect.sqlTypeToMalloyType(postgresDataType);
|
|
@@ -270,7 +278,12 @@ class PostgresConnection {
|
|
|
270
278
|
WHERE table_name = '${table}'
|
|
271
279
|
AND table_schema = '${schema}'
|
|
272
280
|
`;
|
|
273
|
-
|
|
281
|
+
try {
|
|
282
|
+
await this.schemaFromQuery(infoQuery, structDef);
|
|
283
|
+
}
|
|
284
|
+
catch (error) {
|
|
285
|
+
throw new Error(`Error fetching schema for ${tablePath}: ${error}`);
|
|
286
|
+
}
|
|
274
287
|
return structDef;
|
|
275
288
|
}
|
|
276
289
|
async executeSQLRaw(query) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/db-postgres",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.101-dev231107220340",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"prepublishOnly": "npm run build"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@malloydata/malloy": "^0.0.
|
|
26
|
-
"@malloydata/malloy-interfaces": "^0.0.
|
|
25
|
+
"@malloydata/malloy": "^0.0.101-dev231107220340",
|
|
26
|
+
"@malloydata/malloy-interfaces": "^0.0.101-dev231107220340",
|
|
27
27
|
"@types/pg": "^8.6.1",
|
|
28
28
|
"pg": "^8.7.1",
|
|
29
29
|
"pg-query-stream": "4.2.3"
|