keep trying

Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
This commit is contained in:
2026-07-12 12:53:53 +08:00
parent ea3e82e54c
commit d0a64a8043
8 changed files with 55 additions and 80 deletions
+13
View File
@@ -29,6 +29,19 @@ const getFieldValues = (Model, logTag, options = {}) => async (req, res) => {
if (!allowedFields.includes(field) && !dateFields.includes(field))
return R.error(res, "Invalid or restricted field.", 400);
// ─── ENUM / BOOLEAN fields — return the canonical value set, not a DISTINCT
// scan of current rows. A DISTINCT query silently omits valid values
// that just don't happen to exist yet (e.g. is_banned when nobody is
// currently banned), which produces an incomplete filter picklist.
const rawType = Model.rawAttributes[field]?.type;
const typeKey = rawType?.constructor?.key || rawType?.key;
if (typeKey === "ENUM") {
return R.success(res, "Field values retrieved.", rawType.values ?? []);
}
if (typeKey === "BOOLEAN") {
return R.success(res, "Field values retrieved.", ["true", "false"]);
}
if (auditByFields.includes(field)) {
// Filtering must match the audit column's real (bigint) id — returning
// just the display name here previously made buildWhere() compare a