2005/12/18, Michael Bayer <[EMAIL PROTECTED]>: > > On Dec 16, 2005, at 11:24 PM, limodou wrote: > > > > > User.mapper = mapper(Mapper, users, properties = dict( > > relation(Address.mapper, lazy=True, private=True) > > )) > > > > yah where are you seeing that? I think all those are fixed unless > you can point me to one > > > And I also cann't distinguish the differences between OneToMany and > > OneToOne, in the mapping code. Can someone show me the differences > > between them in code? > > Ill show you just where is happens, the thing is I used a bizarre > naming convention when I first wrote it (using LEFT, RIGHT, and > CENTER to mean "one-to-many", "many-to-one", and "many-to-many"), > which is probably why you didnt see it. I might change the > convention to be more sane. > > the general determination of "direction" is here: > > http://www.sqlalchemy.org/trac/browser/sqlalchemy/trunk/lib/ > sqlalchemy/mapping/properties.py#L105 > > the three important methods in determining this are: > > _match_primaries: determine the JOIN conditions of the parent > mapper's table to the child mapper's table. it does this by looping > through the foreign keys for both tables and seeing if they reference > the other table. If we have an association table, we run the method > on that one too to figure out the "secondary join". This method will > also try to determine which column in the JOIN condition is the > foreign key column, i.e. the one that references the primary key of > the other table, and sets that as our "foreign key" property, which > indicates what kind of relationship we are. > > http://www.sqlalchemy.org/trac/browser/sqlalchemy/trunk/lib/ > sqlalchemy/mapping/properties.py#L200 > > _find_dependent: If are not a many-to-many, and we dont yet know > what column in our primary JOIN condition is the "foreign key" (maybe > because the JOIN condition was explicitly specified and we didnt get > to call _match_primaries), which column in the JOIN condition is the > "foreign key" that references a primary key? if there are multiple, > we just need to find one of them. > > http://www.sqlalchemy.org/trac/browser/sqlalchemy/trunk/lib/ > sqlalchemy/mapping/properties.py#L180 > > _get_direction: based on our primary join and our foreign key, are we > the "right" side in a parent/child relationship (many to one), or the > "left" (one to many)? or do we have an association table (a > "secondary" join), and we are neither of those, er, what should I > call that...how about "center" (hence the goofy names)? > > http://www.sqlalchemy.org/trac/browser/sqlalchemy/trunk/lib/ > sqlalchemy/mapping/properties.py#L167 > > > Thanks you all very much. I study the sqlalchemy from the document saved in my scrapbook, and I found the document's pub date is Version: 0.91 Last Updated: 12/06/05 22:20:31. But the newest version in the homepage is Version: 0.91 Last Updated: 12/15/05 13:10:42. So I'v seen the changes, it was my fault, I'm sorry for that.
And I'll continuly study the onetomany and manytomany according to what your supplied to me. Thanks. -- I like python! My Blog: http://www.donews.net/limodou NewEdit Maillist: http://groups.google.com/group/NewEdit ------------------------------------------------------- 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_idv37&alloc_id865&op=click _______________________________________________ Sqlalchemy-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

