[jifty-devel] Regarding refers_to and by on JDBI columns

Nelson Elhage nelhage at bestpractical.com
Mon Jul 16 12:00:20 EDT 2007


On Sat, Jul 14, 2007 at 10:19:00AM -0500, Andrew Sterling Hanenkamp wrote:
> I just found out that my intuition on how "by" works on columns is not
> correct .However, after looking through the code, it seems that it
> would be a decent idea to make the code work the way I expected. What
> I expect to work is this:
> 
> package App::Model::Foo;
> use Jifty::DBI::Schema;
> use App::Record schema {
>    column name => type is 'text';
>    column bar => refers_to App::Model::Bar;
> };
> 
> package App::Model::Bar;
> use Jifty::DBI::Schema;
> use App::Record schema {
>    column name => type is 'text';
>    column foo => refers_to App::Model::Foo by 'bar';
> };

In order to get the behavior you want, replace

refers_to App::Model::Foo by 'bar';

with 

refers_to App::Model::FooCollection by 'bar';

I'm not sure if we want your version to work; I think I would rather see
it die or at least warn that you're using `by' in an invalid place,
since to me referring to a model and referring to a collection are
very distinct and it makes sense to make them clearly different.


- Nelson


More information about the jifty-devel mailing list