@quillsql/node 0.5.3 → 0.5.4

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.
Files changed (3) hide show
  1. package/dist/index.js +17 -12
  2. package/package.json +1 -1
  3. package/src/index.ts +18 -14
package/dist/index.js CHANGED
@@ -126,24 +126,29 @@ class Quill {
126
126
  }
127
127
  else if (runQueryConfig === null || runQueryConfig === void 0 ? void 0 : runQueryConfig.getColumnsForSchema) {
128
128
  const queryResults = yield Promise.all(queries.map((table) => __awaiter(this, void 0, void 0, function* () {
129
- if (!table.viewQuery) {
129
+ if (!table.viewQuery || !table.isSelectStar) {
130
130
  return table;
131
131
  }
132
132
  let limit = "";
133
133
  if (runQueryConfig.limitBy) {
134
134
  limit = ` limit ${runQueryConfig.limitBy}`;
135
135
  }
136
- const queryResult = yield this.targetConnection.query(`${table.viewQuery.replace(/;/, "")} ${limit}`);
137
- const columns = queryResult.fields.map((field) => {
138
- return {
139
- fieldType: (0, schemaConversion_1.convertTypeToPostgres)(field.dataTypeID),
140
- name: field.name,
141
- displayName: field.name,
142
- isVisible: true,
143
- field: field.name,
144
- };
145
- });
146
- return Object.assign(Object.assign({}, table), { columns: columns, rows: queryResult.rows });
136
+ try {
137
+ const queryResult = yield this.targetConnection.query(`${table.viewQuery.replace(/;/, "")} ${limit}`);
138
+ const columns = queryResult.fields.map((field) => {
139
+ return {
140
+ fieldType: (0, schemaConversion_1.convertTypeToPostgres)(field.dataTypeID),
141
+ name: field.name,
142
+ displayName: field.name,
143
+ isVisible: true,
144
+ field: field.name,
145
+ };
146
+ });
147
+ return Object.assign(Object.assign({}, table), { columns: columns, rows: queryResult.rows });
148
+ }
149
+ catch (err) {
150
+ return Object.assign(Object.assign({}, table), { error: "Error fetching columns" });
151
+ }
147
152
  })));
148
153
  results = Object.assign(Object.assign({}, results), { queryResults });
149
154
  if (runQueryConfig === null || runQueryConfig === void 0 ? void 0 : runQueryConfig.fieldsToRemove) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quillsql/node",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "description": "Quill Server SDK for Node.js",
5
5
  "main": "dist/index.js",
6
6
  "module": "./dist/index.js",
package/src/index.ts CHANGED
@@ -195,26 +195,30 @@ export class Quill {
195
195
  } else if (runQueryConfig?.getColumnsForSchema) {
196
196
  const queryResults = await Promise.all(
197
197
  queries.map(async (table) => {
198
- if (!table.viewQuery) {
198
+ if (!table.viewQuery || !table.isSelectStar) {
199
199
  return table;
200
200
  }
201
201
  let limit = "";
202
202
  if (runQueryConfig.limitBy) {
203
203
  limit = ` limit ${runQueryConfig.limitBy}`;
204
204
  }
205
- const queryResult = await this.targetConnection.query(
206
- `${table.viewQuery.replace(/;/, "")} ${limit}`
207
- );
208
- const columns = queryResult.fields.map((field: any) => {
209
- return {
210
- fieldType: convertTypeToPostgres(field.dataTypeID),
211
- name: field.name,
212
- displayName: field.name,
213
- isVisible: true,
214
- field: field.name,
215
- };
216
- });
217
- return { ...table, columns: columns, rows: queryResult.rows };
205
+ try {
206
+ const queryResult = await this.targetConnection.query(
207
+ `${table.viewQuery.replace(/;/, "")} ${limit}`
208
+ );
209
+ const columns = queryResult.fields.map((field: any) => {
210
+ return {
211
+ fieldType: convertTypeToPostgres(field.dataTypeID),
212
+ name: field.name,
213
+ displayName: field.name,
214
+ isVisible: true,
215
+ field: field.name,
216
+ };
217
+ });
218
+ return { ...table, columns: columns, rows: queryResult.rows };
219
+ } catch (err) {
220
+ return { ...table, error: "Error fetching columns" };
221
+ }
218
222
  })
219
223
  );
220
224
  results = { ...results, queryResults };