#69 joinColumn kwarg to MultipleJoin() omits _id on column name

General (125)

The MultipleJoin constructor allows the specification
of a keyword argument 'joinColumn' to specify an
alternate name for the column that holds the Foreign
Key that the join is based upon. Using SQLObject 0.6.1,
this kwarg doesn't seem to work completely correctly.

Attached is a variant on the Address/Person example
that is used in the documentation to demonstrate
MultipleJoins. In addition to the 'addresses'
MultipleJoin, which uses the default foreign key naming
scheme, it adds storage for mailmen; each address has a
single mailman (as a foreign key); Person has a
multiple join over mailmen, returned as
'deliveryLocations'. 'deliveryLocations' uses a
non-default name for the Foreign Key, so the joinColumn
kwarg is required.

As attached, the code does not work; SQLObject
complains that there is 'no such column: mailman'.

Uncomment line 25, comment out line 28, re-run, and the
example works. The fix to the example adds _id to the
specified joinColumn. Although easy to do, this really
shouldn't be required. It can be implied by the fact
that the column name must be a foreign key, and is
inconsistent with naming of foreign key columns
elsewhere (e.g., in select statements). At the very
least, the reference docs should be updated to reflect


  • Russell Keith-Magee

    Test case for joinColumn on MultipleJoin

  • Jonathan Ellis

    Jonathan Ellis - 2005-03-29

    Logged In: YES

    no, this is how it's supposed to work: joinColumn is the sql
    column name

  • Russell Keith-Magee

    Logged In: YES

    I can see that this is what joinColumn does; However, given
    that the named column will always be a Foreign Key, manually
    specifying _id seems redundant. It is also slightly
    inconsistent with the way columns are referred to elsewhere
    in user space (e.g., select statements refer to
    Address.q.PersonID, not person_id).

    Either way, I stick by my final comment: the reference docs
    are unclear on this point. The reference for joinColumn says:

    "So, if you have a table Product, and another table has a
    column ProductNo that points to this table, then you'd use

    It should be joinColumn="ProductNo_id", with a brief note
    explaining the reason for the suffix.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks