-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Search truncates text fields silently #2436
Comments
Ah yeah, that's annoying. Do you think you'd be able to contribute a fix? |
Probably won't have the time but here's the questions that would pop up
If the above is true then maybe something like this could work def query_template
search_attributes.map do |attr|
table_name = query_table_name(attr)
searchable_fields(attr).map do |field|
column_name = column_to_query(field)
column_type = model.columns_hash[column_name].type
# Decide whether to use CHAR(256) based on column type
cast_type = column_type == :text ? "TEXT" : "CHAR(256)"
"LOWER(CAST(#{table_name}.#{column_name} AS #{cast_type})) LIKE ?"
end.join(" OR ")
end.join(" OR ")
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The existing search code when applied to text fields that are longer then 256 characters filters out results silently which is unexpected behavior.
Let's say you have an Post model with a content attribute that's a postgres text column. The queries below can return very different results depending on where in the content text field the query string resides.
I would expect text fields to be as searchable as string fields.
The text was updated successfully, but these errors were encountered: