github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

fernandoluizao / insensitivity

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 2
    • 0
  • Source
  • Commits
  • Network (0)
  • Issues (0)
  • Downloads (2)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (2)
    • 0.0.2
    • 0.0.1
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Case and accent insensitive search for postgresql — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

applying insensible clause in calculations 
fernandoluizao (author)
Mon Oct 19 15:39:52 -0700 2009
commit  95caa209275168b3b664123ee9890c6047314299
tree    b9e4907a52a75df3f2795575a5cfbdd5bb1a9ac2
parent  aad674e67b032378a988f818c1797860c6d354b8
insensitivity /
name age
history
message
file MIT-LICENSE Loading commit data...
file README
file Rakefile
file init.rb
file install.rb
directory lib/
directory tasks/
directory test/
file uninstall.rb
README
Insensitivity
==========

Insensitivity is a rails plugin that helps to do case and accent insensitive searches in PostgreSQL
It change the WHERE conditions to translate the field removing accents and applying lowercase

NOTE: I'm abandonning the *_search fields approach and making the plugin PostgreSQL specific.
If you want to use the old aproach, it is tagged as 0.0.1

Example
=======

Migration:

create_table :foos do |t|
  t.string :field1
  t.string :field2
end

Model:

class Foo < ActiveRecord::Base
 insensible :field1, :field2
end

Foo.find_by_field1('bla')
SELECT * FROM foos 
WHERE TRANSLATE(LOWER(widgets.field1), 
    'âãäåāăąèééêëēĕėęěìíîïìĩīĭóôõöōŏőùúûüũūŭůç', 
    'aaaaaaaeeeeeeeeeeiiiiiiiiooooooouuuuuuuuc') = 'bla'

Foo.find(:first, :conditions => ['field1 = ?', 'bla'], :order => 'field1')
SELECT * FROM foos 
WHERE TRANSLATE(LOWER(widgets.field1), 
    'âãäåāăąèééêëēĕėęěìíîïìĩīĭóôõöōŏőùúûüũūŭůç', 
    'aaaaaaaeeeeeeeeeeiiiiiiiiooooooouuuuuuuuc') = 'bla' 
ORDER BY field1 LIMIT 1


Copyright (c) 2009 Fernando Luizao, released under the MIT license
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server