[Sqlalchemy-tickets] [sqlalchemy] #2859: Mapper.columns is keyed based on `key` attribute not colum
Brought to you by:
zzzeek
|
From: sqlalchemy <mi...@zz...> - 2013-11-06 16:23:55
|
#2859: Mapper.columns is keyed based on `key` attribute not column name
---------------------------+---------------------------------------
Reporter: tisdall | Owner: zzzeek
Type: defect | Status: new
Priority: medium | Milestone:
Component: documentation | Severity: minor - half an hour
Keywords: | Progress State: awaiting triage
---------------------------+---------------------------------------
I'm not sure if this is an issue with the documentation or the
implementation. Basically they don't match.
[http://docs.sqlalchemy.org/en/latest/orm/mapper_config.html#sqlalchemy.orm.mapper.Mapper.columns
The Mapper docs] say "are keyed based on the attribute name defined in the
mapping, not necessarily the key attribute of the Column itself" but I
have a case where this doesn't appear to be true.
Using [http://docs.sqlalchemy.org/en/latest/orm/mapper_config.html#using-
descriptors-and-hybrids the 2nd EmailAddress class in the hybrid docs]
(the first would likely give the same result) I end up getting the "email"
column keyed as "_email".
{{{
inspector = inspect(EmailAddress)
print(dict(inspector.columns))
}}}
results in:
{{{
{'_email': Column('email', String(), table=<email_address>), 'id':
Column('id', Integer(), table=<email_address>, primary_key=True,
nullable=False)}
}}}
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2859>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|