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