-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not compatible with Postgres citext column type #179
Comments
Hi |
not that I know of, I don't hink anyone is actively work on this |
Thanks you for the quick response |
Not that this is always a good idea but you can override some methods. This could obviously break some things when the library updates but I was able to get it working with the current version... # Monkey patch to support citext
module ScopedSearch
class Definition
class Field
def textual?
%i[string text citext].include?(type)
end
def default_operator
@default_operator ||= case type
when :string, :text, :citext then :like
else :eq
end
end
end
def default_fields_for(value, operator = nil)
column_types = [:virtual]
column_types += [:string, :text, :citext] if [nil, :like, :unlike, :ne, :eq].include?(operator)
column_types += [:double, :float, :decimal] if value =~ NUMERICAL_REGXP
column_types += [:integer] if value =~ INTEGER_REGXP
column_types += [:uuid] if value =~ UUID_REGXP
column_types += [:datetime, :date, :timestamp] if (parse_temporal(value))
default_fields.select { |field| !field.set? && column_types.include?(field.type) }
end
end
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It seems that scoped_search ignores any Postgres column using the case-insensitive type of citext in Postgres. When using the
citext
column type for example an email field along with scoped search:scoped_search on: %i[email first_name last_name]
The query generated ignores the email column:
I haven't spent a lot of time on this, but it seems possibly due to the
textual?
function not treating these column types properly:I'll look into this a bit more when I have a minute.
The text was updated successfully, but these errors were encountered: