Read more

Case sensitivity in PostgreSQL

Tobias Kraze
August 01, 2016Software engineer at makandra GmbH

PostgreSQL, unlike MySQL, treats strings as case sensitive in all circumstances.

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

This includes

  • comparison with = and LIKE
  • collision detection in unique indexes

Usually this is fine, but some strings (like emails and usernames) should typically be treated as case insensitive.

There are a few workarounds available:

Probably the best approach is to just convert emails (and usernames) to lowercase within Rails. Popular authentication libraries (like Clearance and Devise) already do this for you.

Posted by Tobias Kraze to makandra dev (2016-08-01 12:06)