refactor: fix conditional ordering logic in folder sorting to ensure correct rank assignment

This commit is contained in:
Piyush Gupta
2025-11-05 03:21:06 +05:30
parent 0229732a6c
commit eff4bcb886

View File

@@ -419,7 +419,7 @@ export const secretFolderDALFactory = (db: TDbClient) => {
.select(
selectAllTableCols(TableName.SecretFolder),
db.raw(
`DENSE_RANK() OVER (ORDER BY ${TableName.SecretFolder}."name" COLLATE "en-x-icu" ${orderDirection}) as rank`
`DENSE_RANK() OVER (ORDER BY ${TableName.SecretFolder}."name" COLLATE "en-x-icu" ${orderDirection === OrderByDirection.ASC ? "ASC" : "DESC"} as rank`
),
db.ref("slug").withSchema(TableName.Environment).as("environment")
)