@malloydata/db-postgres 0.0.239-dev250226010331 → 0.0.239-dev250227145856
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Connection, ConnectionConfig, MalloyQueryData, PersistSQLResults, PooledConnection, QueryDataRow, QueryOptionsReader, QueryRunStats, RunSQLOptions, SQLSourceDef, TableSourceDef, StreamingConnection } from '@malloydata/malloy';
|
|
1
|
+
import { Connection, ConnectionConfig, MalloyQueryData, PersistSQLResults, PooledConnection, QueryDataRow, QueryOptionsReader, QueryRunStats, RunSQLOptions, SQLSourceDef, TableSourceDef, StreamingConnection, SQLSourceRequest } from '@malloydata/malloy';
|
|
2
2
|
import { BaseConnection } from '@malloydata/malloy/connection';
|
|
3
3
|
import { Client, Pool } from 'pg';
|
|
4
4
|
interface PostgresConnectionConfiguration {
|
|
@@ -28,7 +28,7 @@ export declare class PostgresConnection extends BaseConnection implements Connec
|
|
|
28
28
|
get supportsNesting(): boolean;
|
|
29
29
|
protected getClient(): Promise<Client>;
|
|
30
30
|
protected runPostgresQuery(sqlCommand: string, _pageSize: number, _rowIndex: number, deJSON: boolean): Promise<MalloyQueryData>;
|
|
31
|
-
fetchSelectSchema(sqlRef:
|
|
31
|
+
fetchSelectSchema(sqlRef: SQLSourceRequest): Promise<SQLSourceDef | string>;
|
|
32
32
|
private schemaFromQuery;
|
|
33
33
|
fetchTableSchema(tableKey: string, tablePath: string): Promise<TableSourceDef | string>;
|
|
34
34
|
test(): Promise<void>;
|
|
@@ -145,7 +145,13 @@ class PostgresConnection extends connection_1.BaseConnection {
|
|
|
145
145
|
};
|
|
146
146
|
}
|
|
147
147
|
async fetchSelectSchema(sqlRef) {
|
|
148
|
-
const structDef = {
|
|
148
|
+
const structDef = {
|
|
149
|
+
type: 'sql_select',
|
|
150
|
+
...sqlRef,
|
|
151
|
+
dialect: this.dialectName,
|
|
152
|
+
fields: [],
|
|
153
|
+
name: (0, malloy_1.sqlKey)(sqlRef.connection, sqlRef.selectStr),
|
|
154
|
+
};
|
|
149
155
|
const tempTableName = `tmp${(0, crypto_1.randomUUID)()}`.replace(/-/g, '');
|
|
150
156
|
const infoQuery = `
|
|
151
157
|
drop table if exists ${tempTableName};
|
|
@@ -162,7 +168,7 @@ class PostgresConnection extends connection_1.BaseConnection {
|
|
|
162
168
|
await this.schemaFromQuery(infoQuery, structDef);
|
|
163
169
|
}
|
|
164
170
|
catch (error) {
|
|
165
|
-
return `Error fetching schema for ${
|
|
171
|
+
return `Error fetching schema for ${structDef.name}: ${error}`;
|
|
166
172
|
}
|
|
167
173
|
return structDef;
|
|
168
174
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/db-postgres",
|
|
3
|
-
"version": "0.0.239-
|
|
3
|
+
"version": "0.0.239-dev250227145856",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"prepublishOnly": "npm run build"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@malloydata/malloy": "^0.0.239-
|
|
25
|
+
"@malloydata/malloy": "^0.0.239-dev250227145856",
|
|
26
26
|
"@types/pg": "^8.6.1",
|
|
27
27
|
"pg": "^8.7.1",
|
|
28
28
|
"pg-query-stream": "4.2.3"
|