Question about case insensitivity

I was trying out the search in chapter 7 (CRUD Database Operations)

return Acronym.query(on: req).group(.or) { or in
  // 2
  or.filter(\.short == searchTerm)
// 3
  or.filter(\.long == searchTerm)
// 4

From what I can see, the search was case sensitive. I was running with SQLiteDatabase for this test. Is there a way to do it case insensitive. Searching for omg and not getting a hit for OMG seems a bit unusual. Does the db selected have anything to do with this or do I have to do something else for this to work?

@0xtim Can you please help with this when you get a chance? Thank you - much appreciated! :]

@shades so I think you can use ~~ or ~ (can’t remember off the top of my head which one), which is the ILIKE command, which should translate to case-insensitive

Failing that, join the Vapor Discord server at and ask there!

You can get a case-insensitive filter working with the .ilike operator. Try this:

return Acronym.query(on: req).group(.or) { or in
  or.filter(\.short, .ilike, searchTerm)
  or.filter(\.long, .ilike, searchTerm)

Have fun!