@malloydata/db-postgres 0.0.424 → 0.0.426

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.
@@ -82,8 +82,8 @@ export declare class PostgresConnection extends BaseConnection implements Connec
82
82
  fetchTableSchema(tableKey: string, tablePath: string): Promise<TableSourceDef | string>;
83
83
  test(): Promise<void>;
84
84
  connectionSetup(client: Client): Promise<void>;
85
- runSQL(sql: string, { rowLimit }?: RunSQLOptions, rowIndex?: number): Promise<MalloyQueryData>;
86
- runSQLStream(sqlCommand: string, { rowLimit, abortSignal }?: RunSQLOptions): AsyncIterableIterator<QueryRecord>;
85
+ runSQL(sql: string, options?: RunSQLOptions, rowIndex?: number): Promise<MalloyQueryData>;
86
+ runSQLStream(sqlCommand: string, options?: RunSQLOptions): AsyncIterableIterator<QueryRecord>;
87
87
  estimateQueryCost(_: string): Promise<QueryRunStats>;
88
88
  manifestTemporaryTable(sqlCommand: string): Promise<string>;
89
89
  close(): Promise<void>;
@@ -96,7 +96,7 @@ export declare class PooledPostgresConnection extends PostgresConnection impleme
96
96
  drain(): Promise<void>;
97
97
  getPool(): Promise<Pool>;
98
98
  protected runPostgresQuery(sqlCommand: string, _pageSize: number, _rowIndex: number, deJSON: boolean, values?: unknown[]): Promise<MalloyQueryData>;
99
- runSQLStream(sqlCommand: string, { rowLimit, abortSignal }?: RunSQLOptions): AsyncIterableIterator<QueryRecord>;
99
+ runSQLStream(sqlCommand: string, options?: RunSQLOptions): AsyncIterableIterator<QueryRecord>;
100
100
  close(): Promise<void>;
101
101
  }
102
102
  export {};
@@ -319,13 +319,14 @@ class PostgresConnection extends connection_1.BaseConnection {
319
319
  }
320
320
  }
321
321
  }
322
- async runSQL(sql, { rowLimit } = {}, rowIndex = 0) {
323
- var _a;
322
+ async runSQL(sql, options = {}, rowIndex = 0) {
323
+ var _a, _b;
324
324
  const config = await this.readQueryConfig();
325
- return this.runPostgresQuery(sql, (_a = rowLimit !== null && rowLimit !== void 0 ? rowLimit : config.rowLimit) !== null && _a !== void 0 ? _a : DEFAULT_PAGE_SIZE, rowIndex, true);
325
+ return this.runPostgresQuery(this.sqlWithQueryMetadata(sql, options.queryMetadata), (_b = (_a = options.rowLimit) !== null && _a !== void 0 ? _a : config.rowLimit) !== null && _b !== void 0 ? _b : DEFAULT_PAGE_SIZE, rowIndex, true);
326
326
  }
327
- async *runSQLStream(sqlCommand, { rowLimit, abortSignal } = {}) {
328
- const query = new pg_query_stream_1.default(sqlCommand);
327
+ async *runSQLStream(sqlCommand, options = {}) {
328
+ const { rowLimit, abortSignal } = options;
329
+ const query = new pg_query_stream_1.default(this.sqlWithQueryMetadata(sqlCommand, options.queryMetadata));
329
330
  const client = await this.getClient();
330
331
  await this.withTlsHint(() => client.connect());
331
332
  await this.connectionSetup(client);
@@ -407,8 +408,9 @@ class PooledPostgresConnection extends PostgresConnection {
407
408
  totalRows: result.rows.length,
408
409
  };
409
410
  }
410
- async *runSQLStream(sqlCommand, { rowLimit, abortSignal } = {}) {
411
- const query = new pg_query_stream_1.default(sqlCommand);
411
+ async *runSQLStream(sqlCommand, options = {}) {
412
+ const { rowLimit, abortSignal } = options;
413
+ const query = new pg_query_stream_1.default(this.sqlWithQueryMetadata(sqlCommand, options.queryMetadata));
412
414
  let index = 0;
413
415
  // This is a strange hack... `this.pool.query(query)` seems to return the wrong
414
416
  // type. Because `query` is a `QueryStream`, the result is supposed to be a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/db-postgres",
3
- "version": "0.0.424",
3
+ "version": "0.0.426",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -23,7 +23,7 @@
23
23
  "prepublishOnly": "npm run build"
24
24
  },
25
25
  "dependencies": {
26
- "@malloydata/malloy": "0.0.424",
26
+ "@malloydata/malloy": "0.0.426",
27
27
  "@types/pg": "^8.6.1",
28
28
  "pg": "8.7.3",
29
29
  "pg-query-stream": "4.2.3"