Re: [Dbix-class] Could not load Schema Class (Billing::Schema). DBIx::Class::ResultSource::add_relationship(): Malformed relationship condition value '': must be prefixed with 'self.'

2021-01-26 Thread Александр Поволоцкий

Yes, thanks!

I guess this example is required to be in docs.

--

Alex

On 27.01.2021 2:06, Daniel Böhmer wrote:

Hello Alex,

the simple hashref-type defintion expects a pair of column names.

I did the same thing using the coderef-type definition. For an example 
see
https://github.com/dboehmer/coocook/blob/c9b3503f3df44a6817c5402225913815849e4aaa/lib/Coocook/Schema/Result/Unit.pm#L38 



Beware that with a coderef you cannot simply write the name of
the column to be equal but now you actually need to say the
column should be equal to the value of a given column (-ident).

You'll need something like this:

sub {
    my $args = shift;

    return {
    "$args->{foreign_alias}.agreement" => { -ident => 
"$args->{self_alias}.id" },

    "$args->{foreign_alias}.bill"  => undef,
    };
}


Does that work?

Kind regards
Daniel


On 2021-01-26 22:53, Александр Поволоцкий wrote:

Hello

I'm trying to make left join with extra condition

agreements a left join bill_mails bm  on a.id = bm.agreement and 
bm.bill is null


However,

  { "foreign.agreement" => "self.id",
    "foreign.bill" => undef
  },

yields error

 Could not load Schema Class (Billing::Schema).
DBIx::Class::ResultSource::add_relationship(): Malformed relationship
condition value '': must be prefixed with 'self.'

Is it possible to make such a clause without extra view?

---

Alex


___
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/dbix-class@lists.scsys.co.uk


___
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/dbix-class@lists.scsys.co.uk

Re: [Dbix-class] Could not load Schema Class (Billing::Schema). DBIx::Class::ResultSource::add_relationship(): Malformed relationship condition value '': must be prefixed with 'self.'

2021-01-26 Thread Daniel Böhmer

Hello Alex,

the simple hashref-type defintion expects a pair of column names.

I did the same thing using the coderef-type definition. For an example 
see

https://github.com/dboehmer/coocook/blob/c9b3503f3df44a6817c5402225913815849e4aaa/lib/Coocook/Schema/Result/Unit.pm#L38

Beware that with a coderef you cannot simply write the name of
the column to be equal but now you actually need to say the
column should be equal to the value of a given column (-ident).

You'll need something like this:

sub {
my $args = shift;

return {
"$args->{foreign_alias}.agreement" => { -ident => 
"$args->{self_alias}.id" },

"$args->{foreign_alias}.bill"  => undef,
};
}


Does that work?

Kind regards
Daniel


On 2021-01-26 22:53, Александр Поволоцкий wrote:

Hello

I'm trying to make left join with extra condition

agreements a left join bill_mails bm  on a.id = bm.agreement and 
bm.bill is null


However,

  { "foreign.agreement" => "self.id",
    "foreign.bill" => undef
  },

yields error

 Could not load Schema Class (Billing::Schema).
DBIx::Class::ResultSource::add_relationship(): Malformed relationship
condition value '': must be prefixed with 'self.'

Is it possible to make such a clause without extra view?

---

Alex


___
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/dbix-class@lists.scsys.co.uk


___
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/dbix-class@lists.scsys.co.uk