Skip to content

Commit

Permalink
refactor: expicit names in queries (#4850)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwasniew committed Sep 27, 2023
1 parent d3e01d8 commit a060376
Showing 1 changed file with 13 additions and 9 deletions.
Expand Up @@ -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);
}
Expand Down

0 comments on commit a060376

Please sign in to comment.