@malloydata/db-postgres 0.0.98-dev231026204054 → 0.0.98-dev231027183449
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.
|
@@ -14,13 +14,13 @@ interface PostgresConnectionConfiguration {
|
|
|
14
14
|
}
|
|
15
15
|
type PostgresConnectionConfigurationReader = PostgresConnectionConfiguration | (() => Promise<PostgresConnectionConfiguration>);
|
|
16
16
|
export declare class PostgresConnection implements Connection, StreamingConnection, PersistSQLResults {
|
|
17
|
+
readonly name: string;
|
|
18
|
+
private queryConfigReader;
|
|
19
|
+
private configReader;
|
|
17
20
|
private readonly dialect;
|
|
18
21
|
private isSetup;
|
|
19
22
|
private schemaCache;
|
|
20
23
|
private sqlSchemaCache;
|
|
21
|
-
private queryConfigReader;
|
|
22
|
-
private configReader;
|
|
23
|
-
readonly name: any;
|
|
24
24
|
constructor(name: string, queryConfigReader?: PostgresQueryConfigurationReader, configReader?: PostgresConnectionConfigurationReader);
|
|
25
25
|
private readQueryConfig;
|
|
26
26
|
private readConfig;
|
|
@@ -58,7 +58,7 @@ export declare class PostgresConnection implements Connection, StreamingConnecti
|
|
|
58
58
|
}
|
|
59
59
|
export declare class PooledPostgresConnection extends PostgresConnection implements PooledConnection {
|
|
60
60
|
private pool;
|
|
61
|
-
constructor(name: string);
|
|
61
|
+
constructor(name: string, queryConfigReader?: PostgresQueryConfigurationReader, configReader?: PostgresConnectionConfigurationReader);
|
|
62
62
|
isPool(): true;
|
|
63
63
|
drain(): Promise<void>;
|
|
64
64
|
protected runPostgresQuery(sqlCommand: string, _pageSize: number, _rowIndex: number, deJSON: boolean): Promise<MalloyQueryData>;
|
|
@@ -63,13 +63,13 @@ const DEFAULT_PAGE_SIZE = 1000;
|
|
|
63
63
|
const SCHEMA_PAGE_SIZE = 1000;
|
|
64
64
|
class PostgresConnection {
|
|
65
65
|
constructor(name, queryConfigReader = {}, configReader = {}) {
|
|
66
|
+
this.name = name;
|
|
67
|
+
this.queryConfigReader = queryConfigReader;
|
|
68
|
+
this.configReader = configReader;
|
|
66
69
|
this.dialect = new malloy_1.PostgresDialect();
|
|
67
70
|
this.isSetup = false;
|
|
68
71
|
this.schemaCache = new Map();
|
|
69
72
|
this.sqlSchemaCache = new Map();
|
|
70
|
-
this.queryConfigReader = queryConfigReader;
|
|
71
|
-
this.configReader = configReader;
|
|
72
|
-
this.name = name;
|
|
73
73
|
}
|
|
74
74
|
async readQueryConfig() {
|
|
75
75
|
if (this.queryConfigReader instanceof Function) {
|
|
@@ -151,13 +151,13 @@ class PostgresConnection {
|
|
|
151
151
|
return inCache;
|
|
152
152
|
}
|
|
153
153
|
async getClient() {
|
|
154
|
-
const
|
|
154
|
+
const { username: user, password, databaseName: database, port, host, } = await this.readConfig();
|
|
155
155
|
return new pg_1.Client({
|
|
156
|
-
user
|
|
157
|
-
password
|
|
158
|
-
database
|
|
159
|
-
port
|
|
160
|
-
host
|
|
156
|
+
user,
|
|
157
|
+
password,
|
|
158
|
+
database,
|
|
159
|
+
port,
|
|
160
|
+
host,
|
|
161
161
|
});
|
|
162
162
|
}
|
|
163
163
|
async runPostgresQuery(sqlCommand, _pageSize, _rowIndex, deJSON) {
|
|
@@ -326,8 +326,8 @@ class PostgresConnection {
|
|
|
326
326
|
}
|
|
327
327
|
exports.PostgresConnection = PostgresConnection;
|
|
328
328
|
class PooledPostgresConnection extends PostgresConnection {
|
|
329
|
-
constructor(name) {
|
|
330
|
-
super(name);
|
|
329
|
+
constructor(name, queryConfigReader = {}, configReader = {}) {
|
|
330
|
+
super(name, queryConfigReader, configReader);
|
|
331
331
|
this.pool = new pg_1.Pool();
|
|
332
332
|
this.pool.on('acquire', client => client.query("SET TIME ZONE 'UTC'"));
|
|
333
333
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/db-postgres",
|
|
3
|
-
"version": "0.0.98-
|
|
3
|
+
"version": "0.0.98-dev231027183449",
|
|
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.98-
|
|
26
|
-
"@malloydata/malloy-interfaces": "^0.0.98-
|
|
25
|
+
"@malloydata/malloy": "^0.0.98-dev231027183449",
|
|
26
|
+
"@malloydata/malloy-interfaces": "^0.0.98-dev231027183449",
|
|
27
27
|
"@types/pg": "^8.6.1",
|
|
28
28
|
"pg": "^8.7.1",
|
|
29
29
|
"pg-query-stream": "4.2.3"
|