[Dbix-class] nullable column and might_have

Hartmaier Alexander alexander.hartmaier at t-systems.at
Thu Jun 5 12:15:39 GMT 2014


Hi Mitchell,
you've mistaken the direction of the relationship.
The result class with the xxxid column should have a belongs_to relationship to ForeignClass with { join_type => "LEFT" } so that rows where the xxxid column is NULL won't be missing from the resultset if you're joining the relationship.

In ForeignClass you could add a has_many relationship if you need it.

BR Alex

On 2014-06-05 13:54, Mitchell Elutovich wrote:
I have something like the following on a custom result source

__PACKAGE__->add_columns(
  "xxxid",
  { data_type => "INT", default_value => undef, is_nullable => 1, size => 11 },
);

__PACKAGE__->might_have(
  "xxxd",
  "ForeignClass",
  { "foreign.id<http://foreign.id>" => "self.xxxid" },
);

I'm getting the warning:

DBIx::Class::Relationship::HasOne::_validate_has_one_condition(): "might_have/has_one" must not be on columns with is_nullable set to true (MyClass/xxxid). This might indicate an incorrect use of those relationship helpers instead of belongs_to. at ...

I don't understand why this for might_have might be incorrect, doesn't might_have imply it might be null?



_______________________________________________
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



*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
T-Systems Austria GesmbH Rennweg 97-99, 1030 Wien
Handelsgericht Wien, FN 79340b
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
Notice: This e-mail contains information that is confidential and may be privileged.
If you are not the intended recipient, please notify the sender and then
delete this e-mail immediately.
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20140605/a79b84ca/attachment.htm>


More information about the DBIx-Class mailing list