@quillsql/node 0.5.2 → 0.5.3
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 +32 -0
- package/dist/models/Quill.d.ts +1 -0
- package/package.json +1 -1
- package/src/index.ts +38 -1
- package/src/models/Quill.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -124,6 +124,38 @@ class Quill {
|
|
|
124
124
|
});
|
|
125
125
|
return { columns };
|
|
126
126
|
}
|
|
127
|
+
else if (runQueryConfig === null || runQueryConfig === void 0 ? void 0 : runQueryConfig.getColumnsForSchema) {
|
|
128
|
+
const queryResults = yield Promise.all(queries.map((table) => __awaiter(this, void 0, void 0, function* () {
|
|
129
|
+
if (!table.viewQuery) {
|
|
130
|
+
return table;
|
|
131
|
+
}
|
|
132
|
+
let limit = "";
|
|
133
|
+
if (runQueryConfig.limitBy) {
|
|
134
|
+
limit = ` limit ${runQueryConfig.limitBy}`;
|
|
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 });
|
|
147
|
+
})));
|
|
148
|
+
results = Object.assign(Object.assign({}, results), { queryResults });
|
|
149
|
+
if (runQueryConfig === null || runQueryConfig === void 0 ? void 0 : runQueryConfig.fieldsToRemove) {
|
|
150
|
+
results = Object.assign(Object.assign({}, results), { queryResults: queryResults.map((table) => {
|
|
151
|
+
const removedColumns = table.columns.filter((column) => {
|
|
152
|
+
var _a;
|
|
153
|
+
return !((_a = runQueryConfig.fieldsToRemove) === null || _a === void 0 ? void 0 : _a.includes(column.name));
|
|
154
|
+
});
|
|
155
|
+
return Object.assign(Object.assign({}, table), { columns: removedColumns });
|
|
156
|
+
}) });
|
|
157
|
+
}
|
|
158
|
+
}
|
|
127
159
|
else if (runQueryConfig === null || runQueryConfig === void 0 ? void 0 : runQueryConfig.getTables) {
|
|
128
160
|
const queryResult = yield (0, DatabaseHelper_1.getTablesBySchemaByDatabase)(this.targetConnection.databaseType, this.targetConnection.pool, runQueryConfig.schemaNames || runQueryConfig.schema);
|
|
129
161
|
const schemaInfo = yield (0, DatabaseHelper_1.getColumnInfoBySchemaByDatabase)(this.targetConnection.databaseType, this.targetConnection.pool, runQueryConfig.schema, queryResult);
|
package/dist/models/Quill.d.ts
CHANGED
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -158,7 +158,7 @@ export class Quill {
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
private async runQueries(
|
|
161
|
-
queries:
|
|
161
|
+
queries: any[] | undefined,
|
|
162
162
|
pkDatabaseType: "postgresql" | "snowflake" | "bigquery" | "mysql",
|
|
163
163
|
databaseType?: string,
|
|
164
164
|
runQueryConfig?: AdditionalProcessing
|
|
@@ -192,6 +192,43 @@ export class Quill {
|
|
|
192
192
|
};
|
|
193
193
|
});
|
|
194
194
|
return { columns };
|
|
195
|
+
} else if (runQueryConfig?.getColumnsForSchema) {
|
|
196
|
+
const queryResults = await Promise.all(
|
|
197
|
+
queries.map(async (table) => {
|
|
198
|
+
if (!table.viewQuery) {
|
|
199
|
+
return table;
|
|
200
|
+
}
|
|
201
|
+
let limit = "";
|
|
202
|
+
if (runQueryConfig.limitBy) {
|
|
203
|
+
limit = ` limit ${runQueryConfig.limitBy}`;
|
|
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 };
|
|
218
|
+
})
|
|
219
|
+
);
|
|
220
|
+
results = { ...results, queryResults };
|
|
221
|
+
if (runQueryConfig?.fieldsToRemove) {
|
|
222
|
+
results = {
|
|
223
|
+
...results,
|
|
224
|
+
queryResults: queryResults.map((table: any) => {
|
|
225
|
+
const removedColumns = table.columns.filter((column: any) => {
|
|
226
|
+
return !runQueryConfig.fieldsToRemove?.includes(column.name);
|
|
227
|
+
});
|
|
228
|
+
return { ...table, columns: removedColumns };
|
|
229
|
+
}),
|
|
230
|
+
};
|
|
231
|
+
}
|
|
195
232
|
} else if (runQueryConfig?.getTables) {
|
|
196
233
|
const queryResult = await getTablesBySchemaByDatabase(
|
|
197
234
|
this.targetConnection.databaseType,
|
package/src/models/Quill.ts
CHANGED