Skip to content

Commit

Permalink
Skip creating index if not speicifed
Browse files Browse the repository at this point in the history
  • Loading branch information
tushar5526 committed Sep 4, 2023
1 parent ddec668 commit 6f3e9b7
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ export class QueryBuilderService {

for (const index of indexes) {
for (const column of index.columns) {
// if no indexes are specified in grammar, skip
if (column.length === 0) continue;
const indexName = `${schema.title}_${column.join('_')}_idx`;
const columns = column.join(', ');
const statement = `CREATE INDEX ${indexName} ON ${psqlSchema}.${schema.title} (${columns});`;
Expand Down Expand Up @@ -237,8 +239,8 @@ export class QueryBuilderService {
', ',
)})
SELECT ${fields
.map((field) => `${tempTableName}.${field}`)
.join(', ')} FROM ${tempTableName}
.map((field) => `${tempTableName}.${field}`)
.join(', ')} FROM ${tempTableName}
${joinStatements === '' ? ' ' : joinStatements}
WHERE TRUE${whereStatements === '' ? ' ' : whereStatements};`;

Expand Down

0 comments on commit 6f3e9b7

Please sign in to comment.