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. ;) |