phildeman has asked for the wisdom of the Perl Monks concerning the following question:
Help!
I am attempting to use join in DBIx::Class. Perl will read the search component, then ignore the join component.
In the Result packages the code reads as follows:
TblPerson:__PACKAGE__->add_columns( "PID", { data_type => "integer", extra => { unsigned => 1 }, is_auto_increment => 1, is_nullable => 0, }, "FName", { data_type => "varchar", is_nullable => 0, size => 30 }, "MI", { data_type => "char", is_nullable => 1, size => 2 }, "LName", { data_type => "varchar", is_nullable => 0, size => 30 }, "username", { data_type => "varchar", is_nullable => 0, size => 8 }, ); . . . __PACKAGE__->has_many( "tbl_requests", "DB::BSMS::Result::TblRequests", { "foreign.PID" => "self.PID" }, { cascade_copy => 0, cascade_delete => 0 }, );
TblRequests:
__PACKAGE__->add_columns( "RID", { data_type => "integer", extra => { unsigned => 1 }, is_auto_increment => 1, is_nullable => 0, }, "PID", { data_type => "integer", extra => { unsigned => 1 }, is_foreign_key => 1, is_nullable => 0, }, "original_post_date", { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 0 }, "last_update", { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 0 }, "submit_date", { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 }, "status", { data_type => "varchar", is_nullable => 0, size => 20 }, "sent_email", { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 }, ); . . . __PACKAGE__->belongs_to( "p", "DB::BSMS::Result::TblPerson", { PID => "PID" }, { is_deferrable => 1, on_delete => "NO ACTION", on_update => "NO ACT +ION" }, );
method get_user_request_status() { my @proc_requests = $schema->resultset( 'TblRequests' )->search({ -or => [ -and => [ -or => [ 'sent_email' => {'!=', undef }, 'sent_email' => {'!=', '0000-00-00'}, ], ], 'status' => 'Offered', 'status' => 'Denied', 'status' => 'Cancelled' 'status' => 'Conditional Offer', ], }, { join => 'p' } ); return \@proc_requests if @proc_requests; } }
When I exclude the the join component, the search component works fine. However, the
moment I introduce the join, the result set only returns data from TblRequests, and nothing from
TblPerson.
I ran debug, and it only displays the $schema statement upto the closing outter -or bracket "],". When
I press 'n' to go to the next line, it bypasses join component and goes right to the return statement. It simply
ignores the join component.
Any thoughts or suggestions? Thanks.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Problems Using Join in DBIx::Class
by 1nickt (Canon) on Dec 28, 2017 at 02:20 UTC | |
by phildeman (Scribe) on Dec 28, 2017 at 06:31 UTC | |
by soonix (Chancellor) on Dec 28, 2017 at 08:48 UTC | |
by phildeman (Scribe) on Dec 29, 2017 at 03:11 UTC | |
by poj (Abbot) on Dec 29, 2017 at 08:50 UTC | |
by 1nickt (Canon) on Dec 29, 2017 at 04:26 UTC | |
by poj (Abbot) on Dec 28, 2017 at 19:04 UTC | |
by phildeman (Scribe) on Dec 29, 2017 at 02:19 UTC |