@malloydata/db-postgres 0.0.335 → 0.0.336
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.
|
@@ -25,6 +25,7 @@ export declare class PostgresConnection extends BaseConnection implements Connec
|
|
|
25
25
|
isPool(): this is PooledConnection;
|
|
26
26
|
canPersist(): this is PersistSQLResults;
|
|
27
27
|
canStream(): this is StreamingConnection;
|
|
28
|
+
getDigest(): string;
|
|
28
29
|
get supportsNesting(): boolean;
|
|
29
30
|
protected getClient(): Promise<Client>;
|
|
30
31
|
protected runPostgresQuery(sqlCommand: string, _pageSize: number, _rowIndex: number, deJSON: boolean): Promise<MalloyQueryData>;
|
|
@@ -21,50 +21,11 @@
|
|
|
21
21
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
22
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
25
|
-
if (k2 === undefined) k2 = k;
|
|
26
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
27
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
28
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
29
|
-
}
|
|
30
|
-
Object.defineProperty(o, k2, desc);
|
|
31
|
-
}) : (function(o, m, k, k2) {
|
|
32
|
-
if (k2 === undefined) k2 = k;
|
|
33
|
-
o[k2] = m[k];
|
|
34
|
-
}));
|
|
35
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
36
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
37
|
-
}) : function(o, v) {
|
|
38
|
-
o["default"] = v;
|
|
39
|
-
});
|
|
40
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
41
|
-
var ownKeys = function(o) {
|
|
42
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
43
|
-
var ar = [];
|
|
44
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
45
|
-
return ar;
|
|
46
|
-
};
|
|
47
|
-
return ownKeys(o);
|
|
48
|
-
};
|
|
49
|
-
return function (mod) {
|
|
50
|
-
if (mod && mod.__esModule) return mod;
|
|
51
|
-
var result = {};
|
|
52
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
53
|
-
__setModuleDefault(result, mod);
|
|
54
|
-
return result;
|
|
55
|
-
};
|
|
56
|
-
})();
|
|
57
24
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
58
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
59
26
|
};
|
|
60
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61
28
|
exports.PooledPostgresConnection = exports.PostgresConnection = void 0;
|
|
62
|
-
// LTNOTE: we need this extension to be installed to correctly index
|
|
63
|
-
// postgres data... We should probably do this on connection creation...
|
|
64
|
-
//
|
|
65
|
-
// create extension if not exists tsm_system_rows
|
|
66
|
-
//
|
|
67
|
-
const crypto = __importStar(require("crypto"));
|
|
68
29
|
const malloy_1 = require("@malloydata/malloy");
|
|
69
30
|
const connection_1 = require("@malloydata/malloy/connection");
|
|
70
31
|
const pg_1 = require("pg");
|
|
@@ -120,6 +81,16 @@ class PostgresConnection extends connection_1.BaseConnection {
|
|
|
120
81
|
canStream() {
|
|
121
82
|
return true;
|
|
122
83
|
}
|
|
84
|
+
getDigest() {
|
|
85
|
+
// If configReader is an object (not a function), use its properties
|
|
86
|
+
if (typeof this.configReader !== 'function') {
|
|
87
|
+
const { host, port, databaseName, connectionString } = this.configReader;
|
|
88
|
+
const data = `postgres:${host !== null && host !== void 0 ? host : ''}:${port !== null && port !== void 0 ? port : ''}:${databaseName !== null && databaseName !== void 0 ? databaseName : ''}:${connectionString !== null && connectionString !== void 0 ? connectionString : ''}`;
|
|
89
|
+
return (0, malloy_1.makeDigest)(data);
|
|
90
|
+
}
|
|
91
|
+
// Fall back to connection name if config is async
|
|
92
|
+
return (0, malloy_1.makeDigest)(`postgres:${this.name}`);
|
|
93
|
+
}
|
|
123
94
|
get supportsNesting() {
|
|
124
95
|
return true;
|
|
125
96
|
}
|
|
@@ -330,7 +301,7 @@ class PostgresConnection extends connection_1.BaseConnection {
|
|
|
330
301
|
return {};
|
|
331
302
|
}
|
|
332
303
|
async manifestTemporaryTable(sqlCommand) {
|
|
333
|
-
const hash =
|
|
304
|
+
const hash = (0, malloy_1.makeDigest)(sqlCommand);
|
|
334
305
|
const tableName = `tt${hash}`;
|
|
335
306
|
const cmd = `CREATE TEMPORARY TABLE IF NOT EXISTS ${tableName} AS (${sqlCommand});`;
|
|
336
307
|
// console.log(cmd);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/db-postgres",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.336",
|
|
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.
|
|
25
|
+
"@malloydata/malloy": "0.0.336",
|
|
26
26
|
"@types/pg": "^8.6.1",
|
|
27
27
|
"pg": "^8.7.1",
|
|
28
28
|
"pg-query-stream": "4.2.3"
|