@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.
- package/dist/index.js +18 -12
- package/package.json +1 -1
- 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
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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
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 (
|
|
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
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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 };
|