in reply to Re^6: Moose + ORM
in thread Moose + ORM

Would you have used one of those two modules inside a Moose role?

No, I would have just used one of those modules.

The role is actually irrelevant here. Both of those modules do exactly what you are trying to do but are much more featureful and battle-tested (DBIx::Class somewhat more so then Fey::ORM, but Fey::ORM is written by Dave Rolsky who writes some pretty tight code).

Or would you not use Moose at all?

Fey::ORM is written in Moose already, and DBIx::Class will be written in Moose before too much longer so using it now means it will eventually be Mooseified (and i will have to do is upgrade).

-stvn

Replies are listed 'Best First'.
Re^8: Moose + ORM
by Anonymous Monk on Jul 27, 2009 at 14:29 UTC
    Excellent! Thank you for your help.
Re^8: Moose + ORM
by Anonymous Monk on Aug 05, 2009 at 20:12 UTC
    Having played around with Fey::ORM, I am quite convinced that it is a bad route to go.

    Personally, if I were the author of Fey::ORM I would most certainly work to keep the documentation up to date. The example code in the POD is broken -- the interface changes and the docs do not get updated correctly. I have spent much time reading the source code, which is not easy to follow.

    The problem is still the same. If you have a single table then creating an object that represents it is simple -- but as soon as you starting throwing in relationships you are going to start hurting.

    I have two tables that are joined by a cross reference table -- each row of the cross reference table contains one id from the first table, and one id from the second table. I can not for the life of me figure why this won't work:

    package Foo; use Schema; use Fey::ORM::Table; use Fey::SQL; use Fey::Placeholder; my $schema = Schema->Schema(); my $foo_table = $schema->table( 'foo' ); my $bar_table = $schema->table( 'bar' ); my $writer_xref = $schema->table( 'bar_xref' ); has_table $foo_table; my $sql = Fey::SQL->new_select(); $sql->select( 'bar_id' ); $sql->from( $bar_xref ); $sql->where( $bar_xref->column( 'foo_id' ), '=', Fey::Placeholder->new + ); has_many 'bars' => ( table => $schema->table('bar'), select => $sql, bind_params => sub { $_[0]->id }, ); 1;
    But when I instantiate a Foo object, the following error which is so completely useless is spewed forth:
    Use of uninitialized value in join or string at /usr/lib/perl5/site_pe +rl/5.8.8/Fey/ORM/Role/Iterator.pm line 20. Attribute (classes) does not pass the type constraint because: Must be + an array reference of Fey::Object::Table subclasses and you passed [ +] at /usr/lib/perl5/site_perl/5.8.8/Fey/Meta/HasMany.pm line 98 Foo::bars('Movie=HASH(0x9322704)') called at ./foo.pl line 11
    Where do I even begin my long list of complaints? How about not being able to pass in a text string of SQL? Instead I have to make an object. Ugh.

    Thanks for your help, but I am not happy with Fey::ORM. Not one single bit. Perhaps if the Fey::ORM docs were production ready ... perhaps if the author(s) would take a little time to give better examples. I mean ... they do want us to use their code, correct? Perhaps they just want to cause pain and suffering. ;)

      Typo in above post: s/writer_xref/bar_xref/