Open unformatt opened 8 years ago
I've found that migrations names are getting truncated in django_migrations tables:
It looks like all your names get cut in half, which I'm pretty sure neither Django nor django-pyodbc-azure would do on purpose. Could there be something funny with your character encodings, which would make some component along the way use the number of characters as length in bytes (but only for the "name" column)? Perhaps a weird encoding in the file system (because that's where the migration names are taken from)?
It would probably help if you said what operating system your client is on (Mac? Linux? Cygwin?)
I'm on OSX. Having dealt with MS SQL <--> python character encoding nightmares before, I agree it probably lies within there.
Sorry this doesn't pertain exactly to django-pyodbc-azure but I can't find any answers. I've snooped into django/db/migrations/recorder.py and when it saves the name of the migration, it's set to u'0001_initial'
, when I load the same record and print it, it's '0\x00\U0009005f\x00ions\x00\uffff@\U00012068'
.
I can't figure out where to set the character encoding. I've tried in django settings and odbc.ini.
I've tested this manually and the cause is definitely unicode
from django.db.migrations.recorder import MigrationRecorder
m = MigrationRecorder.Migration.objects.get(id=1)
m.name = 'the_correct_name' # this saves correctly
m.name = u'the_correct_name' # this doesn't save correctly
m.save()
My MS SQL DB shows DEFAULT_CHARACTER_SET_NAME
as "iso_1". I added 'driver_charset': 'iso-8859-1'
to database OPTIONS
and this has seemed to fix the issue.
@michiya - what DB charset do you use where you aren't required to have driver_charset defined?
Hi,
I always use UTF-8 encoding when I work with FreeTDS by setting client charset
to UTF-8 in my freetds.conf.
http://www.freetds.org/userguide/freetdsconf.htm
Hope this helps.
Not sure if this is related to django-pyodbc-azure (but I think it is because I tested with MySQL also). So first I run migrations:
Then try to run django, it warns me about migrations:
So try to run migrations again (which fails because I already did):