FIX: Searchable user fields do not always have an integer name (#30223)

This commit is contained in:
Natalie Tay
2024-12-17 08:06:19 +08:00
committed by GitHub
parent a8bdc5f7c5
commit d43d8e0023
2 changed files with 43 additions and 1 deletions

View File

@ -8,7 +8,10 @@ class UserCustomField < ActiveRecord::Base
scope :searchable,
-> do
joins(
"INNER JOIN user_fields ON user_fields.id = REPLACE(user_custom_fields.name, 'user_field_', '')::INTEGER AND user_fields.searchable IS TRUE AND user_custom_fields.name like 'user_field_%'",
"INNER JOIN user_fields ON user_fields.id = REPLACE(user_custom_fields.name, 'user_field_', '')::INTEGER",
).where("user_fields.searchable = TRUE").where(
"user_custom_fields.name ~ ?",
'^user_field_\\d+$',
)
end
end