Skip Menu |
 

This queue is for tickets about the DBIx-Class-ResultSet-WithMetaData CPAN distribution.

Report information
The Basics
Id: 70715
Status: open
Priority: 0/
Queue: DBIx-Class-ResultSet-WithMetaData

People
Owner: Nobody in particular
Requestors: CUBABIT [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.001000
Fixed in: (no value)

Attachments
dbic-withmetadata.tar.gz
DBIx-Class-ResultSet-WithMetaData-1.001000-RT70715.patch



Subject: Cannot create new row object with $rs->new
Download (untitled) / with headers
text/plain 242b
It does not appear possible to create a new row with $schema- Show quoted text
>resultset('Foo')->new({}). An exception is thrown:
Can't locate object method "_row_info" via package "MySchema::Result::**" at ... I have attached a test and a potential patch
Subject: dbic-withmetadata.tar.gz
Download dbic-withmetadata.tar.gz
application/x-gzip 842b

Message body not shown because it is not plain text.

Download (untitled) / with headers
text/plain 466b
I've just hit this as well. The underlying cause is that $rs->new gets proxied to $rs->new_result if $rs is an object not a class. (See the "IMPORTANT" note in http://search.cpan.org/~abraxxa/DBIx- Class/lib/DBIx/Class/ResultSet.pm#new) The new_result() method returns a new result object, not a ResultSet. So a reasonable fix is to add: return $new unless $new->isa('DBIx::Class::ResultSet::WithMetaData'); I've attached a patch with that fix plus a test.
Subject: DBIx-Class-ResultSet-WithMetaData-1.001000-RT70715.patch
Only in DBIx-Class-ResultSet-WithMetaData-1.001000: blib diff -r -u DBIx-Class-ResultSet-WithMetaData-1.001000-orig/lib/DBIx/Class/ResultSet/WithMetaData.pm DBIx-Class-ResultSet-WithMetaData-1.001000/lib/DBIx/Class/ResultSet/WithMetaData.pm --- DBIx-Class-ResultSet-WithMetaData-1.001000-orig/lib/DBIx/Class/ResultSet/WithMetaData.pm 2010-08-16 06:13:32.000000000 -0600 +++ DBIx-Class-ResultSet-WithMetaData-1.001000/lib/DBIx/Class/ResultSet/WithMetaData.pm 2011-09-15 03:38:05.000000000 -0600 @@ -108,6 +108,11 @@ my $self = shift; my $new = $self->next::method(@_); + + # ignore if new() was proxied to new_result() + # https://rt.cpan.org/Ticket/Display.html?id=70715 + return $new unless $new->isa('DBIx::Class::ResultSet::WithMetaData'); + foreach my $key (qw/_row_info was_row id_cols _key_modifiers _hash_modifiers _object_key_modifiers _object_hash_modifiers/) { alias $new->{$key} = $new->{attrs}{$key}; } Only in DBIx-Class-ResultSet-WithMetaData-1.001000: Makefile Only in DBIx-Class-ResultSet-WithMetaData-1.001000: pm_to_blib diff -r -u DBIx-Class-ResultSet-WithMetaData-1.001000-orig/t/basic.t DBIx-Class-ResultSet-WithMetaData-1.001000/t/basic.t --- DBIx-Class-ResultSet-WithMetaData-1.001000-orig/t/basic.t 2010-05-18 08:49:04.000000000 -0600 +++ DBIx-Class-ResultSet-WithMetaData-1.001000/t/basic.t 2011-09-15 03:37:00.000000000 -0600 @@ -1,6 +1,7 @@ #!perl -use Test::More tests => 2; +use Test::More; +use strict; use lib qw(t/lib); use DBICTest; use Data::Dumper; @@ -8,9 +9,11 @@ # set up and populate schema ok(my $schema = DBICTest->init_schema(), 'got schema'); -my $producer_rs = $schema->resultset('Producer')->display(); +$SIG{__DIE__} = \&Carp::confess; +my $producer_rs = $schema->resultset('Producer'); +my $producer_rows = $producer_rs->display(); -is_deeply([sort { $a->{producerid} <=> $b->{producerid} } @{$producer_rs}], [ +is_deeply([sort { $a->{producerid} <=> $b->{producerid} } @{$producer_rows}], [ { 'name' => 'Matt S Trout', 'producerid' => '1' @@ -24,3 +27,8 @@ 'producerid' => '3' } ], 'display returned as expected'); + +# RT70715 https://rt.cpan.org/Ticket/Display.html?id=70715 +ok $producer_rs->new({}); + +done_testing();
Download (untitled) / with headers
text/plain 842b
On Thu Sep 15 05:51:02 2011, TIMB wrote: Show quoted text
> I've just hit this as well. > > The underlying cause is that $rs->new gets proxied to $rs->new_result > if $rs is an object not a > class. (See the "IMPORTANT" note in > http://search.cpan.org/~abraxxa/DBIx- > Class/lib/DBIx/Class/ResultSet.pm#new) > The new_result() method returns a new result object, not a ResultSet.
The under-underlying caue is that DBIC::RS::WMD (ab)uses Moose, without taking the necesary compat steps. Show quoted text
> So a reasonable fix is to add: > > return $new unless $new-
> >isa('DBIx::Class::ResultSet::WithMetaData');
>
No, the correct fix is to sanify the Moose usage in both classes. Especially the resultset component needs a BUILDARGS in addition to both classes needing MooseX::NonMoose. Nothing will sanely work without this. Hit mst in #dbic for more details.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.