Hello, I've got a weird result when trying to insert a row using a result set with 'where'. Here's a sample code:
8<--------------------------ifomichev_test.sql----------------------------- DROP TABLE IF EXISTS `records`; CREATE TABLE `records` ( `record_id` int(10) unsigned NOT NULL auto_increment, `value` varchar(255) default NULL, PRIMARY KEY (`record_id`) ); INSERT INTO `records` VALUES (1,'baba'),(2,'dada'),(3,'kaka'),(4,NULL); 8<-------------------------------Schema.pm--------------------------------- package Schema; use base qw/DBIx::Class::Schema/; __PACKAGE__->load_classes(); 1; 8<---------------------------Schema/Record.pm------------------------------ package Schema::Record; use base qw/DBIx::Class/; __PACKAGE__->load_components( qw/ Core PK::Auto / ); __PACKAGE__->table( 'records' ); __PACKAGE__->add_columns( qw/ record_id value / ); __PACKAGE__->set_primary_key( qw/ record_id / ); 1; 8<-----------------------------test_dbic.pl-------------------------------- #!/usr/bin/perl use strict; use warnings; use Schema; my $schema = Schema->connect( 'DBI:mysql:ifomichev_test', 'root' ); $schema->storage()->debug( 1 ); my $rs = $schema->resultset('Record')->search( { value => { '!=' => undef } }, ); $rs->create( { value => 'papa' } ); #$rs->result_source()->resultset()->create( { value => 'papa' } ); 8<----------------------------------END------------------------------------ Result: 8<----------------------------CURRENT RESULT------------------------------- INSERT INTO records (value) VALUES (?): 'HASH(0xa3d50cc)' 8<----------------------------------END------------------------------------ 'HASH(0xa3d50cc)' appears because a new result is being created with 'value' equal to a structure passed to search method ( { '!=' => undef } ), though I would expect 'value' be overriden with what I passed to the create method (i. e., 'papa'). I worked this around with taking a result source from the result set and then making a new result set (see a commented line above): 8<----------------------------EXPECTED RESULT------------------------------ INSERT INTO records (value) VALUES (?): 'papa' 8<----------------------------------END------------------------------------ Regards, Ivan _______________________________________________ List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class Wiki: http://dbix-class.shadowcatsystems.co.uk/ IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/ Searchable Archive: http://www.mail-archive.com/dbix-class@lists.rawmode.org/