How can i implement ilike in sqlite?

sql`lower(${Recipe.title}) like '%${filters.search.toLowerCase()}%'`
sql`lower(${Recipe.title}) like '%${filters.search.toLowerCase()}%'`
throws an error in turso "LibsqlError: ARGS_INVALID: Arguments do not match SQL parameters: too many parameters, expected 1 found 2". Alternatively is there a way i can reference selected fields? for example if i select
titleLower: sql<string>`lower(${Recipe.title})`.as('titleLower')
titleLower: sql<string>`lower(${Recipe.title})`.as('titleLower')
is there a way i can reference this in a where clause? I know with Kysely you can easily do that but haven't found an answer with drizzle
1 Reply
jpcafe
jpcafeOP9mo ago
then i could do something like like(ref('titleLower'), 'something' ok this works
sql`lower(${Recipe.title}) like ${`%${filters.search.toLowerCase()}%`}`
sql`lower(${Recipe.title}) like ${`%${filters.search.toLowerCase()}%`}`
Want results from more Discord servers?
Add your server