Need Help: `ilike` Function Not Returning Expected Results in Drizzle ORM

Hello Drizzle ORM Community!

I'm currently working with Drizzle ORM in a TypeScript environment using PostgreSQL (specifically, Neon PostgreSQL) and I've encountered a small issue with querying user data using the ilike function for case-insensitive matching. I'm attempting to query tbl_users based on partial user names, but I'm not getting the expected results.

Here's the snippet of my code where I implement the query:

const usersList = await db.query.tbl_users.findMany({
  where: ilike(tbl_users.full_name, input.query), // todo: need to fix.
  columns: {
    full_name: true,
    email: true,
  },
});


I pass the query parameter as jack expecting to retrieve users with names like Jackson Kasi, but instead, I receive an empty array. According to the Drizzle ORM documentation, the ilike should work for PostgreSQL like so:

import { ilike } from "drizzle-orm";
db.select().from(table).where(ilike(table.column, "%llo wor%"));


However, my current implementation doesn't seem to function as expected. Does anyone have experience with this function or can spot what I might be doing wrong? Any suggestions on how to properly use ilike with findMany or corrections to my approach would be greatly appreciated!

Thank you in advance for your help!
Was this page helpful?