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