On Jul 1, 2010, at 6:35 PM, Mike Lewis wrote:

> 
>> Please provide a simple, small example of your problem :-)
>> 
>> Also, is there a reason the order of column creation matters?
>> 
>> Chris
>> 
>> --
>> Simplistix - Content Management, Batch Processing & Python Consulting
>>             -http://www.simplistix.co.uk
> 
> class Foo(object):
>  id = Column(Integer, primary_key=True)
>  foo = Column(Integer, nullable=True)
> 
> class Bar(Base, object):
>  __tablename__ = 'bar'
> 
> then on creation of bar, foo might be first.  I believe this is
> because DeclarativeBase adds new documns with dir() and that returns
> stuff in an arbitrary order.
> 
> I'm trying to use __metaclass__ to make a metaclass for Foo where it
> retains order of the dictionary, but I am getting stumped.

The Column object contains a "sort key" when constructed, against a single 
global value, that is used as a sort key when the Table is generated.  This is 
to get around the fact that the attribute dictionary of the declarative class 
is unordered.   

The mixin columns should copy their "sort key" over, or it should somehow be 
tailored in the declarative base so that the order of the two columns stays 
relatively the same, and perhaps is also tailored to be at the same position 
relative to the other columns in the ultimate table.

I'd welcome any patches in this regard since I don't usually deal with the 
"mixin" feature.


-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@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