When working with Oracle, we use the `convert_unicode` parameter, and
use Python unicode objects everywhere.  This works fabulously, and we
even set `assert_unicode` to 'error' to make sure that nothing else is
ever used.
However, when reflecting a table using the `autoload` keyword, these
properties are not set on the resulting columns.  This leads to
interesting errors such as:

    sqlalchemy.exc.NotSupportedError: (NotSupportedError)
Variable_TypeByValue(): unhandled data type unicode 'INSERT INTO
testtable5 (id, b) VALUES (:id, :b)' {'b': u'test', 'id': None}

Is there a way to instrument the columns by telling the autoload
mechanism that I would like to use `convert_unicode` for the columns
where it makes sense, or by modifying the reflected columns after the
table has been loaded?

We're using SQLAlchemy 0.5.  For convenience, here is a piece of code
to test it with:

    from sqlalchemy import create_engine, MetaData, Table, String,
Integer, CLOB, Column, Sequence

    users_metadata = MetaData()

    table_name = 'testtable'
    testtable = Table(
        table_name, users_metadata,
        Column('id', Integer, Sequence(table_name + '_id_sequence',
start=1, increment=1), primary_key=True),
        Column('b', CLOB(convert_unicode=True,
assert_unicode='error')))

    engine = create_engine('oracle://localhost/...', echo=True)
    connection = engine.connect()
    users_metadata.bind = connection
    testtable.create(engine)

    # works
    connection.execute(testtable.insert(values={'b': u'test'}))

    metadata = MetaData(bind=connection)
    testtable = Table(table_name, metadata, autoload=True)

    # fail
    connection.execute(testtable.insert(values={'b': u'test'}))

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to