#896: Catwalk browse.py 'join_foreign_key' Problem
------------------------+---------------------------------------------------
 Reporter:  [EMAIL PROTECTED]  |       Owner:  anonymous     
     Type:  defect      |      Status:  new           
 Priority:  normal      |   Milestone:  0.9           
Component:  TurboGears  |     Version:  0.9a6         
 Severity:  normal      |    Keywords:  catwalk browse
------------------------+---------------------------------------------------
 In the browse.py file of Catwalk, join_foreign_key has problems if the
 table name contains underscore characters.

 Example:

 class Info(SQLObject):
     data = StringCol()
     user = ForeignKey('User')

 class User(SQLObject):
     class sqlmeta:
         table="tg_user"
     info = MultipleJoin('Info')

 In this example join_foreign_key will look for a field named tgID.  This
 is incorrect, it should be looking for infoID.

 I think this can be fixed by changing the index from 0 to -2.  Rather than
 getting the first element, it should take the second to last element.

 Change line 196 to the following:

 foreign_key = '%sID'% column.joinColumn.split('_')[-2]

 Dan

-- 
Ticket URL: <http://trac.turbogears.org/turbogears/ticket/896>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development

Reply via email to