Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: expicit names in queries #4850

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,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