Max Baker
2008-12-16 01:53:27 UTC
I'm having an issue w/ foreign keys in Jifty. Let's say I have
use the 'name' column to reference the User object. Good.
When I add a new 'Block' object followed by a 'SubBlock' object it
references the Block by its 'id' number instead of by its 'block' name.
Should I have a 'name' column for each Model, or is there a way to tell
it to reference by another column. I tried 'refers_to' but did not get
anywhere.
Question 2 : Can you do make the primary key be two columns. Say for
example instead of creating an id column for SubBlock, just use the two
columns 'block' and 'subblock' together to identify each row? I do that
in other apps, but I use postgres.
Thanks,
-m
Model/User.pm
# (filled out nicely by plugin::ldap)
Model/Block.pm
...
column block =>
type is 'text',
label is 'Block',
is mandatory,
is distinct;
...
Model/Subblock.pm
...
column block =>
refers_to MyApp::Model::Block,
is mandatory;
column subblock =>
type is 'text',
label is 'SubBlock',
is mandatory;
...
Model/Test.pm
...
column test =>
type is 'number',
label is 'Test#';
column block => refers_to MyApp::Model::Block;
column subblock => refers_to MyApp::Model::SubBlock;
column owner_d =>
refers_to MyApp::Model::User;
label is 'Design';
...
When I go into the admin panel and create a new Test object, it will# (filled out nicely by plugin::ldap)
Model/Block.pm
...
column block =>
type is 'text',
label is 'Block',
is mandatory,
is distinct;
...
Model/Subblock.pm
...
column block =>
refers_to MyApp::Model::Block,
is mandatory;
column subblock =>
type is 'text',
label is 'SubBlock',
is mandatory;
...
Model/Test.pm
...
column test =>
type is 'number',
label is 'Test#';
column block => refers_to MyApp::Model::Block;
column subblock => refers_to MyApp::Model::SubBlock;
column owner_d =>
refers_to MyApp::Model::User;
label is 'Design';
...
use the 'name' column to reference the User object. Good.
When I add a new 'Block' object followed by a 'SubBlock' object it
references the Block by its 'id' number instead of by its 'block' name.
Should I have a 'name' column for each Model, or is there a way to tell
it to reference by another column. I tried 'refers_to' but did not get
anywhere.
Question 2 : Can you do make the primary key be two columns. Say for
example instead of creating an id column for SubBlock, just use the two
columns 'block' and 'subblock' together to identify each row? I do that
in other apps, but I use postgres.
Thanks,
-m