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.