hello all,

i need something like TEST_DATABASE_COLLATION, but in a normal django code
-- not in the tests.

i am running the same script in two environments: as a part of unit test and
on it's own and get different results. i suspect the reason for getting
different results is django's way of setting collations. my unit test fails
when TEST_DATABASE_COLLATION option is set to utf8_unicode_ci, but runs ok
if it's utf8_swedish_ci, however i do not know the way to set the collation
for the application database. it seems strange that this option is only
available for testing purposes. does anyone know how do i set different
collation?

the rest of this letter is for the curious ones.
here's the example of the unit test script:

class UnknownErrorTestCase(TestCase):
    fixtures = ['collation_error_db_state.json']
    def testUnknownError(self):
        lang = Language.objects.get(pk='sv')
        movie = Movie.objects.get(pk=10)
        movie.keywords.create(word='män', language=lang)

this test passes if TEST_DATABASE_COLLATION is utf8_swedish_ci and fails if
it's utf8_unicode_ci (throws _mysql_exceptions.IntegrityError). the Keyword
model has uniqueness constraint: unique_together = (("word", "language"),).
the fixture loads a Keyword object whose "word" property is "man". this
happens because 'man' == 'män' if utf8_unicode_ci collation is used, so
trying to insert a new Keyword throws integrity error. the problem arises
when i try to ran these three lines of code outside the unit test script
where the collation is not read from the TEST_DATABASE_COLLATION.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to