Skip Menu |
 

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

Report information
The Basics
Id: 45193
Status: rejected
Priority: 0/
Queue: DBIx-Class

People
Owner: Nobody in particular
Requestors: nonsolosoft [...] diff.org
Cc:
AdminCc:

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



Download (untitled) / with headers
text/plain 7.3k
DB<1> $cont = $schema->resultset('DB::Contents')->find({id=>89}); SELECT me.id, me.project, me.section, me.parent, me.content_level FROM contents me WHERE ( ( me.id = ? OR me.id = ? ) ): '89', '89' DB<2> $cont->set_dyn_attributes({'ciccio'=>1,'pino'=>2}); SELECT me.content, me.customer, me.project_name, me.active, me.status, me.license, me.data, me.ambito, me.project_level, me.file_css, me.hostname, me.url_path, me.dsn, me.lang FROM projects me WHERE ( me.content = ? ): '84' SELECT me.id, me.project, me.section, me.parent, me.content_level FROM contents me WHERE ( me.id = ? ): '84' BEGIN WORK SELECT attribute.attribute_name, me.attribute_value FROM content_attributes me JOIN attributes attribute ON attribute.id = me.attribute WHERE ( ( attribute.attribute_name = ? AND ( project = ? AND me.content = ? ) ) ): 'ciccio', '84', '89' INSERT INTO attributes ( attribute_name, project) VALUES ( ?, ? ): 'ciccio', '84' INSERT INTO content_attributes ( attribute, attribute_value, content) VALUES ( ?, ?, ? ): '31', '1', '89' SELECT attribute.attribute_name, me.attribute_value FROM content_attributes me JOIN attributes attribute ON attribute.id = me.attribute WHERE ( ( attribute.attribute_name = ? AND ( project = ? AND me.content = ? ) ) ): 'pino', '84', '89' INSERT INTO attributes ( attribute_name, project) VALUES ( ?, ? ): 'pino', '84' INSERT INTO content_attributes ( attribute, attribute_value, content) VALUES ( ?, ?, ? ): '32', '2', '89' COMMIT DB<3> $cont->get_dyn_attributes(); BEGIN WORK SELECT attribute.attribute_name, me.attribute_value FROM content_attributes me JOIN attributes attribute ON attribute.id = me.attribute WHERE ( ( content = ? AND me.content = ? ) ): '89', '89' ROLLBACK Column attribute not loaded or not passed to new() prior to insert() on DB::ContentAttributes=HASH(0x2922ba40) trying to resolve relationship (maybe you forgot to call ->reload_from_storage to get defaults from the db) at /usr/pkg/lib/perl5/site_perl/5.10.0/DBIx/Class/Schema.pm line 994 DBIx::Class::Schema::throw_exception('DB=HASH(0x28bfcc50)', 'Column attribute not loaded or not passed to new() prior to i...') called at /usr/pkg/lib/perl5/site_perl/5.10.0/DBIx/Class/ResultSource.pm line 1429 DBIx::Class::ResultSource::throw_exception('DBIx::Class::ResultSource::Table=HASH(0x28c41dd0)', 'Column attribute not loaded or not passed to new() prior to i...') called at /usr/pkg/lib/perl5/site_perl/5.10.0/DBIx/Class/ResultSource.pm line 1207 DBIx::Class::ResultSource::resolve_condition('DBIx::Class::ResultSource::Table=HASH(0x28c41dd0)', 'HASH(0x28a00e90)', 'attribute', 'DB::ContentAttributes=HASH(0x2922ba40)') called at /usr/pkg/lib/perl5/site_perl/5.10.0/DBIx/Class/Relationship/Base.pm line 192 DBIx::Class::Relationship::Base::related_resultset('DB::ContentAttributes=HASH(0x2922ba40)', 'attribute') called at /usr/pkg/lib/perl5/site_perl/5.10.0/DBIx/Class/Row.pm line 1029 DBIx::Class::Row::inflate_result('DB::ContentAttributes', 'DBIx::Class::ResultSource::Table=HASH(0x28c41dd0)', 'HASH(0x292452b0)', 'HASH(0x29228d60)') called at /usr/pkg/lib/perl5/site_perl/5.10.0/DBIx/Class/ResultSet.pm line 966 DBIx::Class::ResultSet::_construct_object('DBIx::Class::ResultSet=HASH(0x29220a50)', 'author', 4) called at /usr/pkg/lib/perl5/site_perl/5.10.0/DBIx/Class/ResultSet.pm line 958 DBIx::Class::ResultSet::next('DBIx::Class::ResultSet=HASH(0x29220a50)') called at lib/DB/Contents.pm line 174 DB::Contents::__ANON__[lib/DB/Contents.pm:177]() called at /usr/pkg/lib/perl5/site_perl/5.10.0/DBIx/Class/Storage/DBI.pm line 782 eval {...} called at /usr/pkg/lib/perl5/site_perl/5.10.0/DBIx/Class/Storage/DBI.pm line 770 DBIx::Class::Storage::DBI::txn_do('DBIx::Class::Storage::DBI::Pg=HASH(0x28c38a70)', 'CODE(0x28f3bca0)') called at /usr/pkg/lib/perl5/site_perl/5.10.0/DBIx/Class/Schema.pm line 617 DBIx::Class::Schema::txn_do('DB=HASH(0x28bfcc50)', 'CODE(0x28f3bca0)') called at lib/DB/Contents.pm line 178 DB::Contents::get_dyn_attributes('DB::Contents=HASH(0x2920cd80)') called at (eval 350)[/usr/pkg/lib/perl5/5.10.0/perl5db.pl:638] line 2 eval '($@, $!, $^E, $,, $/, $\\, $^W) = @saved;package main; $^D = $^D | $DB::db_stop; $cont->get_dyn_attributes();; Here there is the source of both set and get used: sub set_dyn_attributes { my ($self, $attrs) = @_; my $id_project = $self->get_project; my $schema = $self->result_source->schema; my $txn_closure = sub { my $rs = $self->content_attributes->search({project=>$id_project},{join=>['attribute'], columns=>['attribute.attribute_name','attribute_value']}); # da mettere dentro una closure per la transazione for my $k (keys %{$attrs}) { if (! $rs->find({'attribute.attribute_name'=>$k}) ) { my $attr = $schema->resultset('DB::Attributes')->create( { project=>$id_project, attribute_name=>$k } ); my $ca = $attr->create_related('content_attributes', { content=>$self->id, attribute_value=>$attrs->{$k}, }); } else { # the attribute_name for this project exists my $attr = $schema->resultset('DB::Attributes')->find( { project=>$id_project, attribute_name=>$k, } ); my $ca = $attr->find_or_new_related('content_attributes', { content=>$self->id, }); $ca->attribute_value($attrs->{$k}); $ca->insert_or_update; } } }; $schema->txn_do($txn_closure); } sub get_dyn_attributes { my ($self) = shift; my $res = {}; my $schema = $self->result_source->schema; my $txn_closure = sub { my $rs = $self->content_attributes->search({content=>$self->id},{join=>['attribute'], columns=>['attribute.attribute_name','attribute_value']}); while(my $a=$rs->next) { $res->{$a->attribute->attribute_name}=$a->attribute_value; } }; $schema->txn_do($txn_closure); return $res; } The same code on 0.08013: DB<7> $cont->set_dyn_attributes({'zio'=>1,'cantante'=>2}); SELECT me.content, me.customer, me.project_name, me.active, me.status, me.license, me.data, me.ambito, me.project_level, me.file_css, me.hostname, me.url_path, me.dsn, me.lang FROM projects me WHERE ( me.content = ? ): '84' SELECT me.id, me.project, me.section, me.parent, me.content_level FROM contents me WHERE ( me.id = ? ): '84' BEGIN WORK SELECT attribute.attribute_name, me.attribute_value FROM content_attributes me JOIN attributes attribute ON attribute.id = me.attribute WHERE ( ( attribute.attribute_name = ? AND ( project = ? AND me.content = ? ) ) ): 'cantante', '84', '89' INSERT INTO attributes ( attribute_name, project) VALUES ( ?, ? ): 'cantante', '84' INSERT INTO content_attributes ( attribute, attribute_value, content) VALUES ( ?, ?, ? ): '33', '2', '89' SELECT attribute.attribute_name, me.attribute_value FROM content_attributes me JOIN attributes attribute ON attribute.id = me.attribute WHERE ( ( attribute.attribute_name = ? AND ( project = ? AND me.content = ? ) ) ): 'zio', '84', '89' INSERT INTO attributes ( attribute_name, project) VALUES ( ?, ? ): 'zio', '84' INSERT INTO content_attributes ( attribute, attribute_value, content) VALUES ( ?, ?, ? ): '34', '1', '89' COMMIT DB<8> x $cont->get_dyn_attributes(); BEGIN WORK SELECT attribute.attribute_name, me.attribute_value FROM content_attributes me JOIN attributes attribute ON attribute.id = me.attribute WHERE ( ( content = ? AND me.content = ? ) ): '89', '89' COMMIT 0 HASH(0x291bf390) 'author' => 4 'cantante' => 2 'ciccio' => 1 'pino' => 2 'zio' => 1
New DBIC version exposed a potential bug in the user's code. Not a DBIC bug.


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.