Skip to content

Commit b7bf6e8

Browse files
authored
fix: case insensitive filter for attendees on /bookings (calcom#21302)
1 parent 2a93e66 commit b7bf6e8

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

packages/trpc/server/routers/viewer/bookings/get.handler.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -937,27 +937,31 @@ function addAdvancedAttendeeWhereClause(
937937

938938
switch (operator) {
939939
case "endsWith":
940-
fullQuery = fullQuery.where(`Attendee.${key}`, "like", `%${operand}`);
940+
fullQuery = fullQuery.where(`Attendee.${key}`, "ilike", `%${operand}`);
941941
break;
942942

943943
case "startsWith":
944-
fullQuery = fullQuery.where(`Attendee.${key}`, "like", `${operand}%`);
944+
fullQuery = fullQuery.where(`Attendee.${key}`, "ilike", `${operand}%`);
945945
break;
946946

947947
case "equals":
948-
fullQuery = fullQuery.where(`Attendee.${key}`, "=", `${operand}`);
948+
fullQuery = fullQuery.where((eb) =>
949+
eb(eb.fn<string>("lower", [`Attendee.${key}`]), "=", `${operand.toLowerCase()}`)
950+
);
949951
break;
950952

951953
case "notEquals":
952-
fullQuery = fullQuery.where(`Attendee.${key}`, "!=", `${operand}`);
954+
fullQuery = fullQuery.where((eb) =>
955+
eb(eb.fn<string>("lower", [`Attendee.${key}`]), "!=", `${operand.toLowerCase()}`)
956+
);
953957
break;
954958

955959
case "contains":
956-
fullQuery = fullQuery.where(`Attendee.${key}`, "like", `%${operand}%`);
960+
fullQuery = fullQuery.where(`Attendee.${key}`, "ilike", `%${operand}%`);
957961
break;
958962

959963
case "notContains":
960-
fullQuery = fullQuery.where(`Attendee.${key}`, "not like", `%${operand}%`);
964+
fullQuery = fullQuery.where(`Attendee.${key}`, "not ilike", `%${operand}%`);
961965
break;
962966

963967
case "isEmpty":

0 commit comments

Comments
 (0)