Why does every field in a table have a .q. mapping (to get the SQL name of a 
field) except ForeignKeys?  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 Trac.)

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

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to