binarylogic / searchlogic

Searchlogic provides object based searching, common named scopes, and other useful tools.
http://rdoc.info/projects/binarylogic/searchlogic
MIT License
1.39k stars 133 forks source link

Need a Case Insensitive Ordering Option #55

Open gabeodess opened 14 years ago

gabeodess commented 14 years ago

Unfortunately when using postgres the default order is case sensitive such that all Capitalized values come before all lowercase values. This seems counter intuitive and certainly not desired in my project. As far as I can tell there is currently no support for case insensitive ordering with searchlogic. I was able to solve this by adding two new named_scopes in Searchlogic::NamedScopes::Ordering.create_ordering_conditions like so:

      named_scope("iascend_by_#{column}".to_sym, {:order => "upper(#{table_name}.#{column}) ASC"})
      named_scope("idescend_by_#{column}".to_sym, {:order => "upper(#{table_name}.#{column}) DESC"})

Search logic rocks, and I know it's bad practice to be hacking plugins so I'm hoping you will include this in your next release. Let me know what you think!