[sqlalchemy] Elixir: Enum and accented characters (non-ASCII character)

2012-01-16 Thread Pierre Bossé
Hello,

Here is my problem:

I would define a domain of values ​​for a table field. Some values ​​
have accented characters (non-ASCII character).

When generating the DDL for Elixir, a conversion is made on the
values ​​provided by the accented characters and no longer.

Here is my test code:

# -*- coding: iso-8859-1 -*-

from elixir import *

class TestEnum(Entity):
myEnum = Field(Unicode(100),\
 Enum(u'avec é',
  u'avec è',
  u'avec à'),\
 colname='MY_ENUM')

if __name__ == '__main__':
metadata.bind = 'oracle://..:..@..'
metadata.bind.echo = True

setup_all()
drop_all()
create_all()



Here is the generated DDL:

CREATE TABLE __main___testenum (
id INTEGER NOT NULL,
MY_ENUM NVARCHAR2(100),
PRIMARY KEY (id),
CHECK (MY_ENUM IN ('avec é', 'avec è', 'avec à'))
)


By correcting the DDL by hand and creating the table, everything is in
the Oracle DB is correct.

Is there a configuration setting that would correct this situation??

Maybe a bug with Elixir??

Thank you for your answers.

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] Elixir: Enum and accented characters (non-ASCII character)

2012-01-16 Thread Michael Bayer

On Jan 16, 2012, at 7:35 AM, Pierre Bossé wrote:

 Hello,
 
 Here is my problem:
 
 I would define a domain of values ​​for a table field. Some values ​​
 have accented characters (non-ASCII character).
 
 When generating the DDL for Elixir, a conversion is made on the
 values ​​provided by the accented characters and no longer.
 
 Here is my test code:
 
 # -*- coding: iso-8859-1 -*-
 
 from elixir import *
 
 class TestEnum(Entity):
myEnum = Field(Unicode(100),\
 Enum(u'avec é',
  u'avec è',
  u'avec à'),\
 colname='MY_ENUM')
 
 if __name__ == '__main__':
metadata.bind = 'oracle://..:..@..'
metadata.bind.echo = True
 
setup_all()
drop_all()
create_all()
 
 
 
 Here is the generated DDL:
 
 CREATE TABLE __main___testenum (
id INTEGER NOT NULL,
MY_ENUM NVARCHAR2(100),
PRIMARY KEY (id),
CHECK (MY_ENUM IN ('avec é', 'avec è', 'avec à '))
 )

I would gather that iso-8859-1 is not an adequate encoding here, even though it 
does seem to preserve round trips with these characters, making this very 
confusing.   The issue reproduces with SQLite, and SQLAlchemy doesn't do 
anything with the string - doesn't encode it or decode it. If you change 
the encoding of the program to utf-8 it works.   

That this produces ? implies that iso-8859-1 isn't good enough here:

# -*- coding: utf-8-*-

x = u'avec é'

print x.encode('iso-8859-1')

this test, however, produces the garbled character, which also implies 8859 
isn't good enough because the source encoding of the program isn't capturing 
the text correctly:

# -*- coding: iso-8859-1-*-

x = u'avec é'

print x.encode('utf-8')





-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.