#787: SQLObject missing table.q.field mappings for ForeignKey columns.
------------------------------------+---------------------------------------
 Reporter:  [EMAIL PROTECTED]  |       Owner:  anonymous
     Type:  defect                  |      Status:  new      
 Priority:  normal                  |   Milestone:           
Component:  SQLObject               |     Version:  0.9a3    
 Severity:  normal                  |    Keywords:           
------------------------------------+---------------------------------------
 Why does every field in a table have a .q. mapping (to get the SQL name of
 a field) except a ForeignKey?  They definitely have a SQL representation,
 an I really do not want to hard-code the column names.  I -like- being
 flexible.

 (Cross-posted to the development forum.)

 Take the following example:

 {{{
 class AtomChildren(SQLObject):
   parent = ForeignKey('Atom')
   child  = ForeignKey('Atom')
   sort   = IntCol(default = 0)

 class Atom(InheritableSQLObject):
   Name     = UnicodeCol(length=255)
   Parents  = RelatedJoin('Atom', intermediateTable=AtomChildren,
                  joinColumn='child_id',
                  otherColumn='parent_id',
                  addRemoveName="Parent")
   Children = RelatedJoin('Atom', intermediateTable=AtomChildren,
                  joinColumn='parent_id',
                  otherColumn='child_id',
                  addRemoveName="Child")
 }}}

 To do a custom query requires:

 {{{
 result = model.Atom.select(
            AND(model.Atom.q.Name == 'default',
                "atom_children.child=%s" % model.Atom.q.id,
                "atom_children.parent = %d" % node.id))
 }}}

 When it really should be:

 {{{
 result = model.Atom.select(
            AND(model.Atom.q.Name == 'default',
                model.AtomChildren.q.child == model.Atom.q.id,
                model.AtomChildren.q.parent == node.id))
 }}}

 Looking through the code for SQLObject I can't easily see why there would
 be a difference.

  - Matthew

-- 
Ticket URL: <http://trac.turbogears.org/turbogears/ticket/787>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears Tickets" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears-tickets
-~----------~----~----~----~------~----~------~--~---

Reply via email to