Still working on the "lazy" column problem and I was thinking about:

    DBIx::Class::LazyColumns

And in your code:

    package My::Schema::Result::SomeTable;
    use parent 'DBIx::Class';
 
    __PACKAGE__->load_components(
      "LazyColumns",
      "PK",
      "Core",
    );

    __PACKAGE__->table("sometable");
    __PACKAGE__->add_columns(qw/id this that/);
    __PACKAGE__->set_primary_key('id');
    # I think this would have to be done after the primary key
    __PACKAGE__->add_lazy_columns(qw/more columns/);

(I *know* that doing this on a class-based instead of an instance-based basis 
is problematic, but we have technical details which mitigate this problem for 
us)

My strategy for implementing this to internally create:

    package My::Schema::Result::SomeTable::Lazy;
    use Modern::Perl;
    use parent 'DBIx::Class';
 
    __PACKAGE__->load_components(
      "PK",
      "Core",
    );

    __PACKAGE__->table("sometable");
    __PACKAGE__->add_columns(qw/id more columns/);
    __PACKAGE__->set_primary_key('id');

And add this relationship to the original table:

    __PACKAGE__->has_one(
      lazy_columns => 'My::Schema::Result::SomeTable::Lazy',
      undef => { proxy => \...@lazy_columns },
    );

I think I'll have to override new() or insert() to pull off the lazy columns 
from the arguments and create them via the new ::Lazy class to make this 
backwards-compatible.

Does this strategy seem workable?

Cheers,
Ovid
--
Buy the book         - http://www.oreilly.com/catalog/perlhks/
Tech blog            - http://blogs.perl.org/users/ovid/
Twitter              - http://twitter.com/OvidPerl
Official Perl 6 Wiki - http://www.perlfoundation.org/perl6


_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]

Reply via email to