-
Notifications
You must be signed in to change notification settings - Fork 3
Fix case sensitivity in search fields and filter alias matching #68
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
ab12e43
065b41b
d70d4a4
32a8d88
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -17,7 +17,7 @@ def create_filters | |||||
|
|
||||||
| @filter_values.each do |comparate_alias, criteria| | ||||||
| # Find the sql mapping if it exists | ||||||
| map = @column_maps.find { |m| m.alias_name == comparate_alias } | ||||||
| map = @column_maps.find { |m| m.alias_name.downcase == comparate_alias.downcase } | ||||||
|
||||||
| map = @column_maps.find { |m| m.alias_name.downcase == comparate_alias.downcase } | |
| map = @column_maps.find { |m| m.alias_name.casecmp?(comparate_alias) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implementation has a performance issue: the
@search_fields.map(&:downcase)array is created on every iteration of the select block, once for each column_map. This should be computed once before the select block. Additionally, the case-insensitive comparison approach is inconsistent with the codebase - sql_sort.rb usescasecmp?for alias matching (line 37 in sql_sort.rb), which is the idiomatic Ruby approach. Consider refactoring to:downcased_search_fields = @search_fields.map(&:downcase)before the select, then usedowncased_search_fields.include?(cm.alias_name.downcase), or better yet, use@search_fields.any? { |sf| sf.casecmp?(cm.alias_name) }for consistency with sql_sort.rb.