#5-intelligent-groups #23

Merged
jkeffects merged 16 commits from #5-intelligent-groups into main 2024-12-19 09:50:45 +00:00
Showing only changes of commit b4cdf4899a - Show all commits

View file

@ -55,9 +55,10 @@ export default abstract class DynamicQueryBuilder {
offset: number = 0, offset: number = 0,
count: number = 25 count: number = 25
): SelectQueryBuilder<ObjectLiteral> { ): SelectQueryBuilder<ObjectLiteral> {
let query = dataSource.getRepository(queryObj.table).createQueryBuilder(queryObj.table + "_0"); let affix = Math.random().toString(36).substring(2);
let query = dataSource.getRepository(queryObj.table).createQueryBuilder(`${queryObj.table}_${affix}`);
this.buildDynamicQuery(query, queryObj); this.buildDynamicQuery(query, queryObj, affix);
query.offset(offset); query.offset(offset);
query.limit(count); query.limit(count);
@ -68,9 +69,10 @@ export default abstract class DynamicQueryBuilder {
private static buildDynamicQuery( private static buildDynamicQuery(
query: SelectQueryBuilder<ObjectLiteral>, query: SelectQueryBuilder<ObjectLiteral>,
queryObject: DynamicQueryStructure, queryObject: DynamicQueryStructure,
affix: string = "",
depth: number = 0 depth: number = 0
): void { ): void {
const alias = queryObject.table + "_" + depth; const alias = queryObject.table + "_" + affix;
let firstSelect = true; let firstSelect = true;
let selects: Array<string> = []; let selects: Array<string> = [];
@ -97,9 +99,10 @@ export default abstract class DynamicQueryBuilder {
if (queryObject.join) { if (queryObject.join) {
for (const join of queryObject.join) { for (const join of queryObject.join) {
query.leftJoinAndSelect(`${alias}.${join.foreignColumn}`, join.table + "_" + (depth + 1)); let subaffix = Math.random().toString(36).substring(2);
query.leftJoinAndSelect(`${alias}.${join.foreignColumn}`, join.table + "_" + subaffix);
this.buildDynamicQuery(query, join, depth + 1); this.buildDynamicQuery(query, join, subaffix, depth + 1);
} }
} }