You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am having an issue trying to do a StartsWith() on a "citext" column. When the case of the search value doesn't match the data, I don't get the correct results returned.
The condition that is being generated is something like this
WHERE ("ec"."Name" LIKE ($1 || '%') AND (LEFT("ec"."Name", LENGTH($1)) = $1))
The problem seems to be caused by the LEFT/LENGTH part. LEFT seems to be returning the value as a normal "text" string and not a "citext" value so it's not doing a case insensitive comparison.
In my searches, I came across this discussion which I assume is why that condition was added.
I can workaround it with a .ToLower() on the column but that defeats the purpose of the citext. Can anything be done about this?
The text was updated successfully, but these errors were encountered:
Your analysis is correct. PostgreSQL's LEFT() unfortunately returns a text when given a citext (i.e. there's no citext overload. LEFT() is used to implement StartsWith() in order to chop the beginning part of the string for comparison (LIKE is used first to use any existing index).
I pushed a commit that will specifically check for citext and cast the result of LEFT() to a citext, so that comparison is case-insensitive. This is somewhat hacky but it works. It will be released with 2.1.0-preview2.
I am having an issue trying to do a StartsWith() on a "citext" column. When the case of the search value doesn't match the data, I don't get the correct results returned.
The condition that is being generated is something like this
The problem seems to be caused by the LEFT/LENGTH part. LEFT seems to be returning the value as a normal "text" string and not a "citext" value so it's not doing a case insensitive comparison.
In my searches, I came across this discussion which I assume is why that condition was added.
I can workaround it with a .ToLower() on the column but that defeats the purpose of the citext. Can anything be done about this?
The text was updated successfully, but these errors were encountered: