hey robert -
its actually by design that you can assign some other property to a Mapper
which happens to override a column name in the table. you might have that
column set up as a property of a different name on the Mapper, for
example, so there would be no conflict.
However, since its the less usual case when one masks out a column with a
relation intentionally, I can try to make it detect the condition when you
mask one of the table columns with a relation which is otherwise not
present as a property, and raise an exception which basically says,
"specify 'override_ok=True' to ignore this condition".
- mike
Robert Leftwich wrote:
> Having just spent a little time trying to work out why some unit tests
> were
> failing and discovering it was because I had added a backref in the mapper
> with
> the same name as a column in the underlying table (the column being the FK
> of
> the backref) it made me question if this sort of dumb error could be
> detected?
>
> An example using the tables from zblog might help explain my ramblings:
>
> users = Table('users', db,
> Column('user_id', Integer, primary_key=True),
> Column('user_name', String(30), nullable=False),
> Column('fullname', String(100), nullable=False),
> Column('password', String(30), nullable=False),
> Column('groupname', String(20), nullable=False),
> )
>
> blogs = Table('blogs', db,
> Column('blog_id', Integer, primary_key=True),
> Column('owner', Integer, ForeignKey('users.user_id'),
> nullable=False),
> Column('name', String(100), nullable=False),
> Column('description', String(500))
> )
>
> Blog.mapper = mapper(Blog, tables.blogs, properties={
> 'id':tables.blogs.c.blog_id,
> 'owner':relation(user.User, lazy=False, backref='blogs'),
> }, is_primary=True)
>
> Note that the 'owner' relation is also the name of a column in the blogs
> table.
>
> It would be great if a big flashing box popped up to tell me I an idiot
> :-)
>
> Possible?
>
> Robert
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log
> files
> for problems? Stop! Download the new AJAX search engine that makes
> searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
> http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
> _______________________________________________
> Sqlalchemy-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
>
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users