Skip to content

Instantly share code, notes, and snippets.

@midu
Last active August 29, 2015 14:01
Show Gist options
  • Save midu/b7539b51ceca5ea34299 to your computer and use it in GitHub Desktop.
Save midu/b7539b51ceca5ea34299 to your computer and use it in GitHub Desktop.
mysql> select 'Krąków, Poland';
+------------------+
| Krąków, Poland |
+------------------+
| Krąków, Poland |
+------------------+
mysql> select binary 'Krąków, Poland';
+---------------------------+
| binary 'Krąków, Poland' |
+---------------------------+
| Krąków, Poland |
+---------------------------+
mysql> select 'Krąków, Poland' = binary 'Krąków, Poland';
+------------------------------------------------+
| 'Krąków, Poland' = binary 'Krąków, Poland' |
+------------------------------------------------+
| 1 |
+------------------------------------------------+
-- This is the query Rails executes when validating `validates :address, uniqueness: true`
mysql> SELECT 1 AS one FROM `locations` WHERE `locations`.`address` = BINARY 'Krąków, Poland';
Empty set (0.00 sec)
mysql> SELECT 1 AS one FROM `locations` WHERE `locations`.`address` = 'Krąków, Poland';
+-----+
| one |
+-----+
| 1 |
+-----+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment