Hey, I've got an interesting bug using the key attribute to change column names, only on a DateTime type column, in sqlite.
Attached is a sample program that highlights it. t1 is the table definition, the way I want to do it (i.e. I have a schema I can't change, but for consistency in the upper layers I want to refer to the column by a different name). t2 is the way that works, but unfortunately can't use to work around the problem. Submitted to trac as bug 207.
import datetime from sqlalchemy import * metadata = DynamicMetaData(name="test") t1 = Table('t1', metadata, Column('id', Integer, primary_key=True), Column('lastupdated', DateTime, key='last_updated'), ) t2 = Table('t2', metadata, Column('id', Integer, primary_key=True), Column('last_updated', DateTime), ) eng = create_engine("sqlite:///test.db") metadata.connect(eng) metadata.create_all() for t in [t2, t1]: print "trying with table %s" % t.name ins_query = t.insert() d = datetime.datetime(2006,6,14,20,57,37) ins_query.execute(dict(last_updated=d)) sel_q = select([t.c.last_updated]) result = sel_q.execute() row = result.fetchone() print row assert d == row[0], "%r not equal to %r" % (d, row[0])
_______________________________________________ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users