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
this.
Test case for joinColumn on MultipleJoin
Logged In: YES
user_id=657828
no, this is how it's supposed to work: joinColumn is the sql
column name
Logged In: YES
user_id=1262
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
joinColumn="ProductNo"."
It should be joinColumn="ProductNo_id", with a brief note
explaining the reason for the suffix.