@quillsql/node 0.5.3 → 0.5.5

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 +18 -12
  2. package/package.json +1 -1
  3. package/src/index.ts +21 -14
package/dist/index.js CHANGED
@@ -126,24 +126,30 @@ 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 ||
130
+ (!table.isSelectStar && !table.customFieldInfo)) {
130
131
  return table;
131
132
  }
132
133
  let limit = "";
133
134
  if (runQueryConfig.limitBy) {
134
135
  limit = ` limit ${runQueryConfig.limitBy}`;
135
136
  }
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 });
137
+ try {
138
+ const queryResult = yield this.targetConnection.query(`${table.viewQuery.replace(/;/, "")} ${limit}`);
139
+ const columns = queryResult.fields.map((field) => {
140
+ return {
141
+ fieldType: (0, schemaConversion_1.convertTypeToPostgres)(field.dataTypeID),
142
+ name: field.name,
143
+ displayName: field.name,
144
+ isVisible: true,
145
+ field: field.name,
146
+ };
147
+ });
148
+ return Object.assign(Object.assign({}, table), { columns: columns, rows: queryResult.rows });
149
+ }
150
+ catch (err) {
151
+ return Object.assign(Object.assign({}, table), { error: "Error fetching columns" });
152
+ }
147
153
  })));
148
154
  results = Object.assign(Object.assign({}, results), { queryResults });
149
155
  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.5",
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,33 @@ 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 (
199
+ !table.viewQuery ||
200
+ (!table.isSelectStar && !table.customFieldInfo)
201
+ ) {
199
202
  return table;
200
203
  }
201
204
  let limit = "";
202
205
  if (runQueryConfig.limitBy) {
203
206
  limit = ` limit ${runQueryConfig.limitBy}`;
204
207
  }
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 };
208
+ try {
209
+ const queryResult = await this.targetConnection.query(
210
+ `${table.viewQuery.replace(/;/, "")} ${limit}`
211
+ );
212
+ const columns = queryResult.fields.map((field: any) => {
213
+ return {
214
+ fieldType: convertTypeToPostgres(field.dataTypeID),
215
+ name: field.name,
216
+ displayName: field.name,
217
+ isVisible: true,
218
+ field: field.name,
219
+ };
220
+ });
221
+ return { ...table, columns: columns, rows: queryResult.rows };
222
+ } catch (err) {
223
+ return { ...table, error: "Error fetching columns" };
224
+ }
218
225
  })
219
226
  );
220
227
  results = { ...results, queryResults };