[Dbix-class] might_have and is_nullable

matthew couchman (JIC) matthew.couchman at bbsrc.ac.uk
Wed Nov 17 13:47:10 GMT 2010


Thanks Peter, that clarifies things for me.

> -----Original Message-----
> From: Peter Rabbitson [mailto:rabbit+dbic at rabbit.us]
> Sent: 17 November 2010 12:41
> To: Class user and developer list
> Subject: Re: [Dbix-class] might_have and is_nullable
> 
> matthew couchman (JIC) wrote:
> > Hi,
> >
> >
> >
> > I’m getting the warning:
> >
> >
> >
> > "might_have/has_one" must not be on columns with is_nullable set to
> > true. This might indicate an incorrect use of those relationship
> helpers
> > instead of belongs_to.
> >
> >
> >
> > and the documentation also tells me that this is naughty. But surely
> by
> > saying that something /might/ have something it implies that it also
> > might /not/ have that something so it needs to be a nullable value.
> Do I
> > just need to specify it in a different way?
> >
> 
> might_have/has_one are *equivalent* to has_many, they just have
> different
> return expectancy (belongs_to is the opposite relationship to all 3).
> 
> Imagine tables
> CRASH_REPORT (id INTEGER, report TEXT)
> DUI_REPORT (id INTEGER, report TEXT, crash_report_fk INTEGER IS NULL)
> 
> then CRASH_REPORT->might_have (dui_rep => DUI_REPORT...)
> and DUI_REPORT->belongs_to (crash_rep => CRASH_REPORT ... { join_type
> => 'left' })
> 
> indicating that a crash may have an accompanying DUI, and a DUI may be
> filed
> under a crash or standalone.
> 
> belongs_to is the only relationship allowed on the "I have a column
> dedicated to hold someone else's id" side. Patches to make the
> documentation
> clearer on this point sorely needed.
> 
> Cheers!
> 
> _______________________________________________
> 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 at lists.scsys.co.uk


More information about the DBIx-Class mailing list