ERROR : Postgres backed column with a non-deterministic collation
-
What were you trying to do? Perform a search on a dashboard with a Postgres backed column with a non-deterministic collation
-
What did you end up with (logs, or, even better, example apps are great!)?
PG::FeatureNotSupported: ERROR: nondeterministic collations are not supported for LIKE
- What versions are you running?
- Rails (6.1.4)
- administrate (0.17.0)
We have currently worked around the issue locally by doing a class_eval
on Administrate::Search and re-defining the query_template
Administrate::Search.class_eval do
# we need to override the LIKE query to explicitly set the COLLATION so Postgres doesn't complain
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)
"LOWER(CAST(#{table_name}.#{column_name} AS CHAR(256))) LIKE ? COLLATE \"default\""
end.join(" OR ")
end.join(" OR ")
end
end
Not sure if there's a more agnostic approach that would allow for collation support?