title: Case Sensitivity Issue Between MySQL / Postgres
body: <p>I am doing ajax validation when a user signs up for my application to see if the username already exists. The request is made whenever you unfocus/blur the username field. Locally I am using MySQL and on Heroku it's Postgres, so I'm assuming the issue lies there somehow because this functions perfectly locally on my dev machine.</p>
  
  <p>The username registered is <strong>Matt</strong> for example...</p>
  
  <p>Development:</p>
  
  <ul>
  <li>Matt = taken is true</li>
  <li>matt = taken is true</li>
  <li>MATT = taken is true</li>
  <li>MaTt = taken is true, etc...</li>
  </ul>
  
  <p>Production:</p>
  
  <ul>
  <li>Matt = taken is true</li>
  <li>matt = taken is false</li>
  <li>MATT = taken is false</li>
  <li>MaTt = taken is false</li>
  </ul>
  
  <p>And here is the method (you can even see I went a step further to try and force it to downcase, again works locally how it should, but not on production)...</p>
  
  <pre><code>def checkname
  
    scrubb = ActionController::Base.helpers.sanitize(params[:username], :tags =&gt; '')
    user = User.find_by_username(scrubb, :conditions =&gt; [ "lower(username) = ?", scrubb.downcase ])
  
    if user.blank?
      render :json =&gt; { :isAvailable =&gt; true }
    else
      render :json =&gt; { :isAvailable =&gt; false }
    end
  
    return
  
  end
  </code></pre>
  
  <p><em><strong></em>**EDIT*<em>*</em></strong></p>
  
  <p>This is the output of the generated MySQL query: </p>
  
  <pre><code>SELECT `users`.* FROM `users` WHERE `users`.`username` = 'MATT' AND (lower(username) = 'matt') LIMIT 1
  </code></pre>
  
  <p>So, it looks like the real issue is that AND statement Rails is generating. How would I remove  that?</p>