TIL: The SQL-92 spec dictates that CHAR/VARCHAR comparisons
be made after padding each string with spaces to the same length.
That means that using a standard MySQL collation, the two strings
'foo' and 'foo ' are equal.
(ref: https://mariadb.com/kb/en/22-sql-collations-collation/)
The problem (which just bit me after all these years) is essentially:
> query_name = 'foo'
> Thing.create(:name => 'foo ')
> thing = Thing.where(:name => query_name).first # returns created thing
> thing.name == query_name # => false ## ouch
That result seems to violate the POLS to me, but I'd like to hear any
opinions about if and/or where this behavior should be fixed before I
start working on a patch to the MySQL2 gem :-)
--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
http://about.me/hassanschroeder
twitter: @hassan
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yAULGhUDK1NS9BS4Kja%2B7RM6j7bUtH0rVC_7hUbBLCgiQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment