[Dbix-class] Bug with relationships on new objects.

Matt S Trout dbix-class at trout.me.uk
Thu Jan 24 12:34:46 GMT 2008


On Thu, Jan 24, 2008 at 09:28:00AM +0000, Scott Thomson wrote:
> On Jan 23, 2008 6:01 AM, Matt S Trout <dbix-class at trout.me.uk> wrote:
> > On Tue, Jan 22, 2008 at 12:29:50PM +0000, Scott Thomson wrote:
> > > I'm up for writing a test case, I've already got the beginnings of one
> > > against which I used to help me locate the cause of the problem.
> > > However, I'm not at all sure what is the correct behaviour to assert.
> > >
> > > I do think that a 'create'd object should have exactly the same
> > > external behaviour of an inflated object, which is currently not the
> > > case, as to what that behaviour should be I'm not so sure.
> >
> > How does it differ?
> >
> > So far as I can tell the question is as to whether the column is present
> > or not, which can be true or false whether the object was constructed
> > via new() or inflate_result().
> 
> Indeed, and this does cause differing external behaviour. Calling the
> rel accessor when the object has been created and hence the column is
> not set - returns all rows in the foreign table because no WHERE
> clause gets generated. Whereas if the same object is inflated - the
> column is set to 'undef', a where clause of fk = NULL is generated and
> no rows are returned.

Which is, as I said, nothing to do with new vs. inflate_result.

If you pass 'col => undef' to new(), you get the fk = NULL.

If you use the 'columns' resultset attr to restrict the col set to not
include the column, you get the 'column does not exist'[0] behaviour.

But all this is academic; if !has_column_loaded we should just be throwing
an exception, not creating the resultset anyway.

Who fancies having a go at a patch? :)

[0] which you call 'column is not set', which is almost accurate but not
quite :)

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/



More information about the DBIx-Class mailing list