not sure what you mean by "descriptor" here.  Here's a test.  show me how to 
reproduce the broken behavior:

from sqlalchemy import *
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()

t = Table('t', Base.metadata,
        Column('user_id', Integer, primary_key=True),
        Column('data', String)
    )
class A(Base):
    __table__ = t

    user_id = t.c.user_id
    user_data = t.c.data

a1 = A()
a1.user_id = 5
assert a1.user_id == 5

a1.user_data = 'some data'
assert a1.user_data == 'some data'


On May 6, 2013, at 1:42 PM, Michael Nachtigal 
<[email protected]> wrote:

> I'm using a declarative mapping in combination with reflection, and I'm 
> providing some custom renaming of column names in the mapped class, as 
> demonstrated below.
> 
> temp_user = self.metadata.tables['user_t']
> class MappedUser(Base):
>     __table__ = temp_user
>     user_number =  temp_user.c.user_id
>     user_id = temp_user.c.user_id
>     user_identifier = temp_user.c.user_id
> 
> I'm running into this strange issue though: I expected that I could use as a 
> descriptor any of the attributes, user_number, user_id, or user_identifier, 
> on an instance of this class to obtain the corresponding value in that 
> object's field, but it doesn't work for the attribute named the same as the 
> column name (the second attribute in the example above): If u is an instance 
> of this class, then u.user_number and u.user_identifier give me the 
> appropriate numeric result, but u.user_id gives me a Column object (which I 
> don't want). I thought that maybe this attribute was being overridden by the 
> column object because of its special name (and maybe it is), but if I delete 
> the line "user_id = temp_user.c.user_id", then the instance u will lose that 
> attribute as well.
> 
> Can someone kindly explain what's happening? How can I restore the desired 
> behavior for the user_id attribute?
> 
> Thanks very much for your time and reply,
> Mike
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to