This project is archived and is in readonly mode.
validates_uniqueness_of unicode aware field length
-
CancelProfileIsBroken
- Tag set to bugmash
-
Elise Huard
there seems to be a problem indeed - the validates_uniqueness select statement doesn't seem to work with utf8
so verified with mysql
I get outright errors with postgresql, while the encoding is UTF8 and so should work.
linked to 2883 i thinkadded tests, and i'll now look for a fix
-
Elise Huard
sorry about the lack of punctuation, there were line breaks in there.
-
Elise Huard
well, i updated the patch: this fix works for postgresql and sqlite3, still not for mysql though.
-
Elise Huard
and now a clean patch.
-
Pratik
- Assigned user set to Jeremy Kemper
-
Elise Huard
rebased against master
-
Rizwan Reza
not reproducible
-1 The patch fails on master.
Created an event whose title, with limit taken into account, is not unique. <false> is not true. -
Elad Meidar
-1 Patch applies on master but fails test, i was unable to trace the generated SQL in the tests log to see what is really going on. Since mb_chars[x,x] is obviously working, i suspect the DB is the one to blame. (MySQL)
1) Failure: test_validate_uniqueness_with_limit_and_utf8(UniquenessValidationTest) [./test/cases/validations/uniqueness_validation_test.rb:246:in `test_validate_uniqueness_with_limit_and_utf8' ./test/cases/../../lib/active_record/test_case.rb:57:in `with_kcode' ./test/cases/validations/uniqueness_validation_test.rb:241:in `test_validate_uniqueness_with_limit_and_utf8' ./test/cases/../../lib/../../activemodel/lib/../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in `__send__' ./test/cases/../../lib/../../activemodel/lib/../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in `run']: Created an event whose title, with limit taken into account, is not unique. <false> is not true. -
Elise Huard
exactly - it works for postgres and sqlite3, but not for mysql.
-
Jeremy Kemper
Works for mysql if you regenerate your test dbs. Drop both dbs and recreate with
rake mysql:build_databases. This corrects the default charset and collation. -
Repository
- State changed from new to committed
(from [c5896bfd8432f6b7a1c6cb06486c5c85eafe9450]) validate uniqueness with limit in utf8
[#2653 state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/c5896bfd8432f6b7a1c6cb06486c5c... -
Repository
(from [f6f04f1549cea33385323b6a1fd2c58855927d15]) validate uniqueness with limit in utf8
[#2653 state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/f6f04f1549cea33385323b6a1fd2c5... -
Jeremy Kemper
- Tag cleared.
-
Elise Huard
I found what makes the test pass (and is also the condition for it to work for mysql: explicit utf8 encoding. I copied the little hack from another test.
-
Jeremy Kemper
Elise, tests already pass for me on mysql. Why is this patch needed?
-
Jeremy Kemper
(first do
rake mysql:rebuild_databasesto fix the old test database's charset and collation) -
Elise Huard
Jeremy, i think your DB is properly configured (for utf8 encoding) - as you can see from Elad's comments (and mine), the mysql still failed, as opposed to the other db's.
this patch checks for that, by doing a query and seeing if the select works properly. I use the same extra bit of code that is used in the test_validate_case_insensitive_uniqueness.
It's a bit of a hack, but i tried different things, like removing the 'BINARY' = connection.case_sensitive_equality_operator for is_utf8? , but that resulted in collation errors in the mysql database, which seems to have LATIN_C1 encoding.
-
Elise Huard
aha, sorry, missed your comment. Ignore the patch then, sorry.
-
Jeremy Kemper
Elise, this would be a useful bit of code for test/connections/native_mysql/connection.rb so we can fail fast and advise a database rebuild instead of leaving Rails testers with odd, unexplained test failures.
