FastJack wrote:

No, it doesn't. I know the arrayref generates valid sql as I can
extract it from the DBIC::Profiler output and run it manually. It finds the data I want. I have also manually constructed 'from' as a complex data structure (see below), but always the same error: "DBIx::Class::ResultSet::single(): No such relationship 'speciality' at ...."

"No such relationship" means, you haven't defined the relationship in
the Schema::Foo-Package with belongs_to or has_many. As far as I know
 you can't simply use the table-name in the join-definition.

Yes, I'm sure you're right. I came to the same conclusion before I left
off. I tried to define the relationship in Schema::Foo, but cannot find the right syntax.

The problem is Schema::Foo is based on table foo. Table foo has a foreign key to table bar, which itself has a foreign key to table baz. I want to retrieve a column (speciality) in baz.

The relationships between bar and baz is defined in Schema::Bar and Schema::Baz, not Schema::Foo.

So I tried this in Schema::Foo:

__PACKAGE__->add_relationship('speciality', 'Schema::Baz',
  {
    'me.bar_id' => 'bar.id',
    'bar.baz_id' => 'baz.id',
  }, );

Generates the following error:

Caught exception in MyApp::Controller::Search->db_lookup "DBIx::Class::ResultSet::pager(): Invalid rel cond key bar.baz_id at ....". Does it mean invalid relationship condition key?

But it feels like I might be on the right lines now?
--
Richard Jones


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

Reply via email to