I have an error when trying a search insensitive f...
# orm-help
r
I have an error when trying a search insensitive filtering with Prisma 3.13.0 and Sqlite3, did I do something wrong or is it Sqlite3 related?
prisma.cities.findFirst({
where: {
name: {
equals: name,
mode: "insensitive",
},
},
});
j
https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#mode
• Supported by the PostgreSQL and MongoDB connectors only
r
Thanks Jason 👍
j
You’re welcome!
r
It works with Sqlite3 if I use startsWith, good enough.
🤷 1
So in the end this works for me,
j
hahaha I guess
startsWith: wholeString
is effectively the same thing as
equals
r
prisma.cities.findFirst({
where: {
name: {
startsWith: name,
endsWith: name,
},
},
});
j
Wait… you aren’t using a case-insensitive search there though.
r
Yes name is a variable
j
I got that. I mean that if the case in the database is different, that query won’t find the result.
r
search byName?name=quiltoriti returns the record with name: "Quiltoriti",
Actually it worked
j
wait… How? Is that set somewhere else? Is SQLlite3 case insensitive?
r
Nope I didn''t set it anywhere else
j
Maybe your table definition?
r
I don't think so because if I use just where: { name: name } it doesn't return the record.
but
where: { name: { startsWith: name } },
returns the record case insentively
j
That implies that
startsWith
and
endsWith
are inherently case-insensitive, doesn’t it?
r
As I need an exact match I added EndsWith
Seems they are.
j
This sounds… buggy
At least startsWith is inconsistent.
r
For my actual case I consider it a feature 😅
j
I’d be careful about relying on this behavior.
r
But agreed that can be suprising.
j
That could be fixed removed at any time.
👍 1
r
I'm moving soon to PosgreSQL so it's just temporary.
j
Gotcha. Right on then.
r
Thanks a lot for your help Jason
j
No need for
prisma.queryRaw
then.
You’re very welcome. Have a great day!
r
Likewise!