@malloydata/db-postgres 0.0.79 → 0.0.80-dev230824170739
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.
|
@@ -13,6 +13,7 @@ interface PostgresConnectionConfiguration {
|
|
|
13
13
|
}
|
|
14
14
|
type PostgresConnectionConfigurationReader = PostgresConnectionConfiguration | (() => Promise<PostgresConnectionConfiguration>);
|
|
15
15
|
export declare class PostgresConnection implements Connection, StreamingConnection, PersistSQLResults {
|
|
16
|
+
private readonly dialect;
|
|
16
17
|
private isSetup;
|
|
17
18
|
private schemaCache;
|
|
18
19
|
private sqlSchemaCache;
|
|
@@ -55,38 +55,15 @@ 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");
|
|
58
59
|
const pg_1 = require("pg");
|
|
59
60
|
const pg_query_stream_1 = __importDefault(require("pg-query-stream"));
|
|
60
61
|
const crypto_1 = require("crypto");
|
|
61
|
-
const postgresToMalloyTypes = {
|
|
62
|
-
'character varying': 'string',
|
|
63
|
-
'name': 'string',
|
|
64
|
-
'text': 'string',
|
|
65
|
-
'date': 'date',
|
|
66
|
-
'integer': 'number',
|
|
67
|
-
'bigint': 'number',
|
|
68
|
-
'double precision': 'number',
|
|
69
|
-
'timestamp without time zone': 'timestamp',
|
|
70
|
-
'oid': 'string',
|
|
71
|
-
'boolean': 'boolean',
|
|
72
|
-
// ARRAY: "string",
|
|
73
|
-
'timestamp': 'timestamp',
|
|
74
|
-
'"char"': 'string',
|
|
75
|
-
'character': 'string',
|
|
76
|
-
'smallint': 'number',
|
|
77
|
-
'xid': 'string',
|
|
78
|
-
'real': 'number',
|
|
79
|
-
'interval': 'string',
|
|
80
|
-
'inet': 'string',
|
|
81
|
-
'regtype': 'string',
|
|
82
|
-
'numeric': 'number',
|
|
83
|
-
'bytea': 'string',
|
|
84
|
-
'pg_ndistinct': 'number',
|
|
85
|
-
};
|
|
86
62
|
const DEFAULT_PAGE_SIZE = 1000;
|
|
87
63
|
const SCHEMA_PAGE_SIZE = 1000;
|
|
88
64
|
class PostgresConnection {
|
|
89
65
|
constructor(name, queryConfigReader = {}, configReader = {}) {
|
|
66
|
+
this.dialect = new malloy_1.PostgresDialect();
|
|
90
67
|
this.isSetup = false;
|
|
91
68
|
this.schemaCache = new Map();
|
|
92
69
|
this.sqlSchemaCache = new Map();
|
|
@@ -232,10 +209,10 @@ class PostgresConnection {
|
|
|
232
209
|
for (const row of result.rows) {
|
|
233
210
|
const postgresDataType = row['data_type'];
|
|
234
211
|
let s = structDef;
|
|
235
|
-
let malloyType =
|
|
212
|
+
let malloyType = this.dialect.sqlTypeToMalloyType(postgresDataType);
|
|
236
213
|
let name = row['column_name'];
|
|
237
214
|
if (postgresDataType === 'ARRAY') {
|
|
238
|
-
malloyType =
|
|
215
|
+
malloyType = this.dialect.sqlTypeToMalloyType(row['element_type']);
|
|
239
216
|
s = {
|
|
240
217
|
type: 'struct',
|
|
241
218
|
name: row['column_name'],
|
|
@@ -252,7 +229,7 @@ class PostgresConnection {
|
|
|
252
229
|
name = 'value';
|
|
253
230
|
}
|
|
254
231
|
if (malloyType) {
|
|
255
|
-
s.fields.push({
|
|
232
|
+
s.fields.push({ ...malloyType, name });
|
|
256
233
|
}
|
|
257
234
|
else {
|
|
258
235
|
s.fields.push({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/db-postgres",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.80-dev230824170739",
|
|
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.
|
|
22
|
+
"@malloydata/malloy": "^0.0.80-dev230824170739",
|
|
23
23
|
"@types/pg": "^8.6.1",
|
|
24
24
|
"pg": "^8.7.1",
|
|
25
25
|
"pg-query-stream": "4.2.3"
|