fix(api): qualify guarantor filter columns

This commit is contained in:
avicenan
2026-03-09 17:00:36 +07:00
parent 34b913fc59
commit b067a82151

View File

@ -6,18 +6,19 @@ import { PatientGuarantor } from "entity";
export class PatientGuarantorModel { export class PatientGuarantorModel {
static async list(filterObj = {}, filterAny: string = ""): Promise<SelectQueryBuilder<any>> { static async list(filterObj = {}, filterAny: string = ""): Promise<SelectQueryBuilder<any>> {
const repo = OrmHelper.DB.getRepository(PatientGuarantor); const repo = OrmHelper.DB.getRepository(PatientGuarantor);
let whereAttr: string[] = []; let whereAttr = [];
let whereVal: any = {}; let whereVal: any = {};
if (filterObj && Object.keys(filterObj).length > 0) { if (filterObj) {
whereAttr = [...whereAttr, ...CommonHelper.handleQueryFilter(filterObj, "patient_guarantor").whereAttr]; const filterResult = CommonHelper.handleQueryFilter(filterObj);
whereVal = { ...whereVal, ...CommonHelper.handleQueryFilter(filterObj, "patient_guarantor").whereVal }; whereAttr = [...whereAttr, ...filterResult.whereAttr];
whereVal = { ...whereVal, ...filterResult.whereVal };
} }
if (filterAny && filterAny !== "" && filterAny !== null && filterAny !== undefined) { if (filterAny && filterAny !== "" && filterAny !== null && filterAny !== undefined) {
const filterResult = CommonHelper.handleFilter({ const filterResult = CommonHelper.handleFilter({
filter: JSON.stringify({ any: filterAny }), filter: JSON.stringify({ any: filterAny }),
col_any_eq: [], col_any_eq: [],
col_any_like: ["patient_guarantor.name", "patient_guarantor.phone"], col_any_like: ["guarantor_name", "phone"],
}); });
if (filterResult.whereAttr && filterResult.whereAttr !== "") { if (filterResult.whereAttr && filterResult.whereAttr !== "") {