Skip to content
Merged

Dev #583

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions packages/api/src/routers/hackathon/admin/attendee-where.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ export const buildAttendeeWhere = (input: {
// Escaped so a literal % or _ in a name searches for that character instead
// of turning into a wildcard.
const pattern = `%${term.replace(/[\\%_]/g, (c) => `\\${c}`)}%`;
// The user table gets its own alias, written by hand. Inside the relational
// roster query (db.query...findMany) Drizzle renders every column in this
// template against the participants alias, so `${users.id}` came out as
// "hackathonParticipants"."id" (a uuid) compared with user_id (text) and
// every search answered 500.
clauses.push(
sql`(
${hackathonParticipants.firstName} ilike ${pattern}
Expand All @@ -49,9 +54,9 @@ export const buildAttendeeWhere = (input: {
or ${hackathonParticipants.major} ilike ${pattern}
or ${hackathonParticipants.whyAttend} ilike ${pattern}
or exists (
select 1 from ${users}
where ${users.id} = ${hackathonParticipants.userId}
and (${users.name} ilike ${pattern} or ${users.email} ilike ${pattern})
select 1 from ${users} as attendee_user
where attendee_user."id" = ${hackathonParticipants.userId}
and (attendee_user."name" ilike ${pattern} or attendee_user."email" ilike ${pattern})
)
)`,
);
Expand Down
Loading
Loading