Skip to content

Commit 29a87a2

Browse files
committed
refactor(cli): use toBool helper for consistent boolean conversion
- Added toBool() helper for converting various truthy values - Replaced manual boolean checks with toBool() for consistency - Handles numeric 0/1, string 't'/'f', and boolean values
1 parent 4aa46ad commit 29a87a2

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

cli/lib/checkup.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ export async function getAlteredSettings(client: Client, pgMajorVersion: number
356356

357357
for (const row of result.rows) {
358358
// Filter for non-default settings (is_default = 0 means non-default)
359-
if (row.is_default === 0 || row.is_default === false) {
359+
if (!toBool(row.is_default)) {
360360
const name = row.tag_setting_name;
361361
const settingValue = row.tag_setting_value;
362362
const unit = row.tag_unit || "";
@@ -577,7 +577,7 @@ export async function getInvalidIndexes(client: Client, pgMajorVersion: number =
577577
relation_name: String(transformed.relation_name || ""),
578578
index_size_bytes: indexSizeBytes,
579579
index_size_pretty: formatBytes(indexSizeBytes),
580-
supports_fk: transformed.supports_fk === true || transformed.supports_fk === 1,
580+
supports_fk: toBool(transformed.supports_fk),
581581
};
582582
});
583583
}
@@ -600,8 +600,8 @@ export async function getUnusedIndexes(client: Client, pgMajorVersion: number =
600600
reason: String(transformed.reason || ""),
601601
idx_scan: parseInt(String(transformed.idx_scan || 0), 10),
602602
index_size_bytes: indexSizeBytes,
603-
idx_is_btree: transformed.idx_is_btree === true || transformed.idx_is_btree === "t",
604-
supports_fk: transformed.supports_fk === true || transformed.supports_fk === 1,
603+
idx_is_btree: toBool(transformed.idx_is_btree),
604+
supports_fk: toBool(transformed.supports_fk),
605605
index_size_pretty: formatBytes(indexSizeBytes),
606606
};
607607
});
@@ -742,7 +742,7 @@ export async function getRedundantIndexes(client: Client, pgMajorVersion: number
742742
index_size_bytes: indexSizeBytes,
743743
table_size_bytes: tableSizeBytes,
744744
index_usage: parseInt(String(transformed.index_usage || 0), 10),
745-
supports_fk: transformed.supports_fk === true || transformed.supports_fk === 1,
745+
supports_fk: toBool(transformed.supports_fk),
746746
index_definition: String(transformed.index_definition || ""),
747747
index_size_pretty: formatBytes(indexSizeBytes),
748748
table_size_pretty: formatBytes(tableSizeBytes),

0 commit comments

Comments
 (0)