1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-09 00:18:00 +01:00

refactor: expicit names in queries (#4850)

This commit is contained in:
Mateusz Kwasniewski 2023-09-27 15:17:04 +02:00 committed by GitHub
parent d3e01d84d9
commit a06037625d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,18 +29,22 @@ export class DependentFeaturesReadModel implements IDependentFeaturesReadModel {
}
async getParentOptions(child: string): Promise<string[]> {
const result = await this.db('features as f')
.where('f.name', child)
.select('f.project');
const result = await this.db('features')
.where('features.name', child)
.select('features.project');
if (result.length === 0) {
return [];
}
const rows = await this.db('features as f')
.leftJoin('dependent_features as df', 'f.name', 'df.child')
.where('f.project', result[0].project)
.andWhere('f.name', '!=', child)
.andWhere('df.child', null)
.select('f.name');
const rows = await this.db('features')
.leftJoin(
'dependent_features',
'features.name',
'dependent_features.child',
)
.where('features.project', result[0].project)
.andWhere('features.name', '!=', child)
.andWhere('dependent_features.child', null)
.select('features.name');
return rows.map((item) => item.name);
}